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
3f200a10
Commit
3f200a10
authored
Jul 29, 2019
by
Pierre Dittgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove special case for xlsx format
parent
172d3f64
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
10 deletions
+2
-10
validata_core/__init__.py
validata_core/__init__.py
+2
-10
No files found.
validata_core/__init__.py
View file @
3f200a10
...
...
@@ -295,25 +295,17 @@ def repair(source, schema_descriptor, **repair_options):
# And source body rows
body_rows
=
list
(
stream
.
iter
())
return
headers
,
body_rows
,
stream
.
format
return
headers
,
body_rows
# Gets schema content
schema_field_names
=
[
f
.
get
(
'name'
)
for
f
in
schema_descriptor
.
get
(
'fields'
)]
# consume source to get headers and content
try
:
headers
,
body_rows
,
stream_format
=
consume_source
(
source
,
**
repair_options
)
headers
,
body_rows
=
consume_source
(
source
,
**
repair_options
)
except
StopIteration
:
return
(
source
,
[])
# Special case for XSLX format
# => remove empty trailing columns
if
stream_format
==
'xlsx'
:
empty_cols_nb
=
len
(
list
(
itertools
.
takewhile
(
lambda
h
:
h
is
None
or
h
==
''
,
headers
[::
-
1
])))
if
empty_cols_nb
:
headers
=
headers
[:
-
empty_cols_nb
]
body_rows
=
[
row
[:
-
empty_cols_nb
]
for
row
in
body_rows
]
# Create dataset for easier post processing
dataset
=
tablib
.
Dataset
(
*
body_rows
,
headers
=
[
h
if
h
else
EMPTY_HEADER
for
h
in
headers
])
...
...
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