Commit ad136e78 authored by Bruno Duyé's avatar Bruno Duyé

dataset.json: add dimensions_values_labels

parent 98bc26be
......@@ -39,6 +39,7 @@ Options:
import logging
import os
import sys
from collections import defaultdict
import toolz
from babel import numbers
......@@ -60,6 +61,13 @@ PROVIDER_JSON = dict(
region='US',
)
DIMENSIONS_VALUES_LABELS = {
'FREQ': {
'A': 'Annually',
'Q': 'Quarterly',
'M': 'Monthly',
},
}
log = logging.getLogger(__name__)
......@@ -123,6 +131,7 @@ def treat_dataset(dataset_dict, appendix_path):
dataset_name = None
# Iterate through dataset source files
dataset_json_series_list = [] # to be written in dataset.json
dimensions_values_labels = defaultdict(dict)
for dataset_source_file_info in dataset_dict['files']:
dataset_source_filename = dataset_source_file_info['filename']
log.debug(dataset_source_filename)
......@@ -142,10 +151,16 @@ def treat_dataset(dataset_dict, appendix_path):
if current_observations_file:
# This is the end of a series (so, not the beginning of the first one)
current_observations_file.close()
# Do the dimensional stuff
dataset_dimension_code = dataset_dict["dimension_code"]
dataset_dimension_value_code = dataset_source_file_info["dimension_value_code"]
concept_code = slugify(observation_dict["LineDescription"])
dimensions = {
dataset_dict["dimension_code"]: dataset_source_file_info["dimension_value_code"], # Ex: 'FREQ': 'Q'
"concept": slugify(observation_dict["LineDescription"]),
dataset_dimension_code: dataset_dimension_value_code, # Ex: 'FREQ': 'Q'
"concept": concept_code,
}
dimensions_values_labels[dataset_dimension_code][dataset_dimension_value_code] = DIMENSIONS_VALUES_LABELS[dataset_dimension_code][dataset_dimension_value_code]
dimensions_values_labels['concept'][concept_code] = observation_dict["LineDescription"]
dataset_json_series_list.append({
'code': series_code,
'name': observation_dict['LineDescription'],
......@@ -170,7 +185,7 @@ def treat_dataset(dataset_dict, appendix_path):
dataset_dict["dimension_code"]: dataset_dict["dimension_label"],
'concept': 'Concept',
},
# 'dimensions_values_labels': dimensions_values_labels, # TODO: manually add frequencies labels
'dimensions_values_labels': dimensions_values_labels,
})
return dataset_code, dataset_name
......
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