Commit 3f200a10 authored by Pierre Dittgen's avatar Pierre Dittgen

Remove special case for xlsx format

parent 172d3f64
......@@ -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])
......
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