From e82890bab71236ac5402793b2d372f75df13582f Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Wed, 8 May 2024 19:01:01 +0000 Subject: [PATCH] fix(logic): save headers; - Save headers in stream iteration in `load_csv`. --- ckanext/xloader/loader.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ckanext/xloader/loader.py b/ckanext/xloader/loader.py index 6d97a667..b7a38472 100644 --- a/ckanext/xloader/loader.py +++ b/ckanext/xloader/loader.py @@ -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): @@ -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):