...
 
Commits (2)
## 0.5.4
- Fix 'duplicate-header' crash
## 0.5.3
- Add 'extra-header' translation
......
......@@ -12,7 +12,7 @@ with readme_filepath.open('rt', encoding='utf-8') as fd_in:
setup(
name='validata_core',
version='0.5.3',
version='0.5.4',
description="Validata Core library",
long_description=LONG_DESCRIPTION,
......
......@@ -192,6 +192,7 @@ def repair_core(dataset: tablib.Dataset, schema_field_names):
last_nonempty_header_col = None
first_nonempty_header_col = None
empty_header_cols = []
duplicate_header_map = {}
for i, head in enumerate(dataset.headers):
......@@ -214,11 +215,19 @@ def repair_core(dataset: tablib.Dataset, schema_field_names):
append_col(rejected_cols_dataset, dataset.get_col(i), head)
continue
# Move duplicate columns in a special dataset
# Rename and move duplicate columns in a special dataset
if head in column_names_dict:
ver = duplicate_header_map.get(head) or 1
fixed_head = '{}~{}'.format(head, ver)
duplicate_header_map[head] = ver + 1
report.append(goodtables.Error(code='duplicate-header',
message_substitutions={'column-number': i+1, 'column-name': head}))
append_col(rejected_cols_dataset, dataset.get_col(i), head)
message_substitutions={
'column-name': head,
'fixed-column-name': fixed_head,
# not used by Validata but needed to avoid
# a KeyError in message substitution
'column_numbers': ''}))
append_col(rejected_cols_dataset, dataset.get_col(i), fixed_head)
# Normal case
else:
......