...
 
Commits (3)
......@@ -186,11 +186,17 @@ def generate_series(ds_dir, source_dir, dimension_codes):
for xml_file in source_dir.glob('*.xml'):
xml_info = load_series_xml_file(xml_file)
# Get series code
ts_code = xml_info['code']
if not '.' in ts_code:
log.warning("Time series code [%s] doesn't contain datasetcode as a prefix", ts_code)
else:
ts_code = ts_code[ts_code.find('.')+1:]
# Get series name
ts_name = xml_info['name']
# Get periods
periods, obs = xml_info['periods'], xml_info['obs']
obs_addon_cols, obs_addon_values = xml_info['obs_addon_cols'], xml_info['obs_addon_values']
......@@ -209,6 +215,8 @@ def generate_series(ds_dir, source_dir, dimension_codes):
series_info = {
'code': ts_code,
}
if ts_name:
series_info['name'] = ts_name
# Using structure info if available
if dimension_codes:
......@@ -307,7 +315,7 @@ def load_structure_xml_file(ds_code, structure_file: Path):
if in_codelist:
# Code id
# Code id (dimension value)
if elt.tag == CODE_TAG:
if evt == 'start':
current_code = elt.attrib.get('value')
......@@ -316,16 +324,18 @@ def load_structure_xml_file(ds_code, structure_file: Path):
current_codelist['values'][current_code] = code_name
in_code = (evt == 'start')
# Name
# Name (dimension label)
if elt.tag == NAME_TAG:
# Code name
if not in_code:
# Code list name
if evt == 'start':
current_codelist_name_dict[elt.attrib.get(LANG_ATT)] = norm_space(elt.text)
# Description (dimension value label)
if elt.tag == DESCRIPTION_TAG:
if in_code:
if evt == 'start':
current_code_name_dict[elt.attrib.get(LANG_ATT)] = norm_space(elt.text)
# Code list name
else:
if evt == 'start':
current_codelist_name_dict[elt.attrib.get(LANG_ATT)] = norm_space(elt.text)
# Use conceptRef as code for dimensions instead of codelist id which can have duplicate...
codelists = [{'id': concept, 'name': cl['name'], 'values':cl['values']} for concept, cl in zip(concepts, codelists)]
......