diff --git a/ckanext/xloader/loader.py b/ckanext/xloader/loader.py index daddc534..f5291b14 100644 --- a/ckanext/xloader/loader.py +++ b/ckanext/xloader/loader.py @@ -174,6 +174,7 @@ def load_csv(csv_filepath, resource_id, mimetype='text/csv', logger=None): try: with UnknownEncodingStream(csv_filepath, file_format, decoding_result, skip_rows=skip_rows) as stream: + stream.save(**save_args) # have to save headers for row in stream: for _index, _cell in enumerate(row): if isinstance(_cell, str): @@ -184,6 +185,7 @@ def load_csv(csv_filepath, resource_id, mimetype='text/csv', logger=None): except (EncodingError, UnicodeDecodeError): with Stream(csv_filepath, format=file_format, encoding=SINGLE_BYTE_ENCODING, skip_rows=skip_rows) as stream: + stream.save(**save_args) # have to save headers for row in stream: for _index, _cell in enumerate(row): if isinstance(_cell, str): diff --git a/ckanext/xloader/tests/test_loader.py b/ckanext/xloader/tests/test_loader.py index a8b23b53..3eacd5a0 100644 --- a/ckanext/xloader/tests/test_loader.py +++ b/ckanext/xloader/tests/test_loader.py @@ -1049,7 +1049,7 @@ def test_boston_311(self, Session): u"", u"ONTIME", u"Open", - u" ", + u"", # " " transforms to "" u"Street Light Outages", u"Public Works Department", u"Street Lights", @@ -1081,14 +1081,14 @@ def test_boston_311(self, Session): u"", u"ONTIME", u"Open", - u" ", + u"", # " " transforms to "" u"Graffiti Removal", u"Property Management", u"Graffiti", u"Graffiti Removal", u"PROP_GRAF_GraffitiRemoval", u"PROP", - u" https://mayors24.cityofboston.gov/media/boston/report/photos/595f0000048560f46d94b9fa/report.jpg", + u"https://mayors24.cityofboston.gov/media/boston/report/photos/595f0000048560f46d94b9fa/report.jpg", # strip white spaces u"", u"522 Saratoga St East Boston MA 02128", Decimal("1"), @@ -1113,14 +1113,14 @@ def test_boston_311(self, Session): u"", u"ONTIME", u"Open", - u" ", + u"", # " " transforms to "" u"Graffiti Removal", u"Property Management", u"Graffiti", u"Graffiti Removal", u"PROP_GRAF_GraffitiRemoval", u"PROP", - u" https://mayors24.cityofboston.gov/media/boston/report/photos/595efedb048560f46d94b9ef/report.jpg", + u"https://mayors24.cityofboston.gov/media/boston/report/photos/595efedb048560f46d94b9ef/report.jpg", # strip white spaces u"", u"965 Bennington St East Boston MA 02128", Decimal("1"),