

def test_download_blob_then_upload_as_dataframe_then_read_dataset(self):

    def datatypeid_from_header_and_format(header, format):
        if (format == 'csv'):
            if (header == 'wh'):
                return DataTypeIds.GenericCSV
            else:
                return DataTypeIds.GenericCSVNoHeader
        elif (format == 'tsv'):
            if (header == 'wh'):
                return DataTypeIds.GenericTSV
            else:
                return DataTypeIds.GenericTSVNoHeader
        elif (format == 'txt'):
            return DataTypeIds.PlainText
        else:
            self.assertTrue(False, 'Unexpected format')

    def split_blob_name(blob_name):
        (name, format) = blob_name.lower().split('.')
        if (format != 'txt'):
            (name, header) = name.split('_')
        else:
            header = 'nh'
        return (name, format, header)
    for blob_name in settings.storage.blobs:
        print(blob_name)
        (name, format, header) = split_blob_name(blob_name)
        original_data = self.blob.get_blob_to_bytes(settings.storage.container, blob_name)
        self._write_blob_contents(blob_name, original_data)
        original_dataframe = pd.read_csv(BytesIO(original_data), header=(0 if (header == 'wh') else None), sep=(',' if (format == 'csv') else ('\t' if (format == 'tsv') else '\n')), encoding='utf-8-sig')
        dataset_name = (('unittest' + name) + id_generator())
        description = ('safe to be deleted - ' + dataset_name)
        data_type_id = datatypeid_from_header_and_format(header, name)
        self.workspace.datasets.add_from_dataframe(original_dataframe, data_type_id, dataset_name, description)
        dataset = self.workspace.datasets[dataset_name]
        self.assertIsNotNone(dataset)
        result_data = dataset.read_as_binary()
        self._write_serialized_frame(blob_name, result_data)
        result_dataframe = dataset.to_dataframe()
        assert_frame_equal(original_dataframe, result_dataframe)

dataset/ETHPy150Open Azure/Azure-MachineLearning-ClientLibrary-Python/tests/roundtriptests.py RoundTripTests.test_download_blob_then_upload_as_dataframe_then_read_dataset/VarMisuse@326/484 `format`->`name`