Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Validata
Validata Core
Commits
64e83217
Commit
64e83217
authored
Aug 08, 2019
by
Pierre Dittgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix duplicate-header crash
parent
94be30f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
validata_core/__init__.py
validata_core/__init__.py
+12
-3
No files found.
validata_core/__init__.py
View file @
64e83217
...
...
@@ -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
#
M
ove duplicate columns in a special dataset
#
Rename and m
ove 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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment