def test_load_read_csv(self): # nosetests -s -v dlstats.tests.fetchers.test_bis:BISUtilsTestCase.test_load_read_csv d = FETCHER_DATASETS.copy() print() for dataset_code, dataset in d.items(): if dataset_code != "DSRP": continue filepath = FETCHER_DATASETS[dataset_code]["filepath"] datas = dataset['datas'] fileobj = io.StringIO(datas)#, newline=os.linesep) rows, headers, release_date, dimension_keys, periods = bis.local_read_csv(fileobj=fileobj) self.assertTrue('KEY' in headers) line1 = bis.csv_dict(headers, next(rows)) #TODO: test values ? print(dataset_code, dimension_keys, line1) self.assertEqual(len(dimension_keys), FETCHER_DATASETS[dataset_code]["dimensions_count"])
def test_load_read_csv(self): """Load special csv - direct from string """ # nosetests -s -v dlstats.tests.fetchers.test_bis:BISUtilsTestCase.test_load_read_csv d = {} #d['CNFS'] = DATASETS['CNFS'].copy() d = DATASETS.copy() for dataset_code, dataset in d.items(): datas = dataset['datas'] fileobj = io.StringIO(datas, newline="\n") rows, headers, release_date, dimension_keys, periods = bis.local_read_csv(fileobj=fileobj) #len(dimension_keys) #print(headers) self.assertTrue('KEY' in headers) line1 = bis.csv_dict(headers, next(rows))
def test_load_read_csv(self): # nosetests -s -v dlstats.tests.fetchers.test_bis:BISUtilsTestCase.test_load_read_csv d = FETCHER_DATASETS.copy() print() for dataset_code, dataset in d.items(): if dataset_code != "DSRP": continue filepath = FETCHER_DATASETS[dataset_code]["filepath"] datas = dataset['datas'] fileobj = io.StringIO(datas) #, newline=os.linesep) rows, headers, release_date, dimension_keys, periods = bis.local_read_csv( fileobj=fileobj) self.assertTrue('KEY' in headers) line1 = bis.csv_dict(headers, next(rows)) #TODO: test values ? print(dataset_code, dimension_keys, line1) self.assertEqual( len(dimension_keys), FETCHER_DATASETS[dataset_code]["dimensions_count"])