Commit 6f99e97b authored by Bruno Duyé's avatar Bruno Duyé

Download: source data -> datasets.json: reorganize information

parent 0702d43d
......@@ -116,21 +116,25 @@ def main():
if args['--limit_nb_datasets'] and nb_tables_downloaded >= int(args['--limit_nb_datasets']):
break
nb_tables_downloaded += 1
dataset_json = [] # dataset information to be written in datasets.json
for frequency_dict in dataset_frequencies:
frequency_code = frequency_dict['FrequencyID']
url = API_URLs['series_data'].format(api_user_id=api_user_id, appendix_code=appendix_code,
dataset_code=dataset_code, frequency_code=frequency_code)
dataset_filename = slugify(dataset_code) + '-' + frequency_code + '.json'
dataset_filepath = os.path.join(appendix_path, dataset_filename)
dataset_json = get_from_api(url, raise_on_errors=False)
if dataset_json:
write_json_file(dataset_filepath, dataset_json)
datasets_json.append({
'dataset_code': dataset_code,
'dimension_label': 'FREQ',
dataset_observations_json = get_from_api(url, raise_on_errors=False)
if dataset_observations_json:
write_json_file(dataset_filepath, dataset_observations_json)
dataset_json.append({
'dimension_code': frequency_code,
'filename': dataset_filename,
})
datasets_json.append({
'dataset_code': dataset_code,
'dimension_label': 'FREQ',
'files': dataset_json,
})
# Write datasets.json
write_json_file(os.path.join(appendix_path, "datasets.json"), datasets_json)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment