Commit 955e5e58 authored by Bruno Duyé's avatar Bruno Duyé

Fix: some series are empty

parent 962255d5
......@@ -157,14 +157,16 @@ def treat_dataset(dataset_code, source_filepath, target_dir, datasets_names_by_c
series_iterator = iter_series(source_filepath)
for series_dict in series_iterator:
# Generate SDMX compatible series code
series_code = generate_series_code({k: list(v.keys())[0]
for k, v in series_dict['dimensions_values'].items()})
# Create series observations file
with (dataset_dir / (series_code + '.tsv')).open('w', encoding='utf-8') as observations_file:
observations_file.write("PERIOD\tVALUE\n")
sorted_observations = sorted(series_dict['observations'], key=lambda e: e[0])
for observation in sorted_observations:
observations_file.write("\t".join(observation) + "\n")
sorted_observations = sorted(series_dict['observations'], key=lambda e: e[0])
if sorted_observations:
with (dataset_dir / (series_code + '.tsv')).open('w', encoding='utf-8') as observations_file:
observations_file.write("PERIOD\tVALUE\n")
for observation in sorted_observations:
observations_file.write("\t".join(observation) + "\n")
if limit_nb_dataset_series:
if nb_series_converted >= limit_nb_dataset_series:
break
......
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