Skip to content

Commit

Permalink
fix(logic): save headers;
Browse files Browse the repository at this point in the history
- Save headers in stream iteration in `load_csv`.
  • Loading branch information
JVickery-TBS committed May 8, 2024
1 parent 97b793b commit e82890b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ckanext/xloader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def load_csv(csv_filepath, resource_id, mimetype='text/csv', dialect=None, encod
force_encoding=bool(encoding),
logger=(logger if not has_logged_dialect else None)) as stream:
# (canada fork only): strip trailing whitespace from cell values
stream.save(**save_args) # have to save headers
for row in stream:
for _index, _cell in enumerate(row):
if isinstance(_cell, str):
Expand All @@ -229,6 +230,7 @@ def load_csv(csv_filepath, resource_id, mimetype='text/csv', dialect=None, encod
with Stream(csv_filepath, format=file_format, encoding=SINGLE_BYTE_ENCODING,
skip_rows=skip_rows) as stream:
# (canada fork only): strip trailing whitespace from cell values
stream.save(**save_args) # have to save headers
for row in stream:
for _index, _cell in enumerate(row):
if isinstance(_cell, str):
Expand Down

0 comments on commit e82890b

Please sign in to comment.