Move strip() call to parse_csv()

This commit is contained in:
jeremystretch 2023-03-13 10:37:27 -04:00
parent d75f2da720
commit 291626a999
2 changed files with 1 additions and 4 deletions

View File

@ -226,10 +226,6 @@ class ImportForm(BootstrapMixin, forms.Form):
reader = csv.reader(stream)
headers, records = parse_csv(reader)
# Strip whitespace from headers
headers = {k.strip(): v for k, v in headers.items()}
records = [{k.strip(): v for k, v in record.items()} for record in records]
# Set CSV headers for reference by the model form
self._csv_headers = headers

View File

@ -195,6 +195,7 @@ def parse_csv(reader):
# `site.slug` header, to indicate the related site is being referenced by its slug.
for header in next(reader):
header = header.strip()
if '.' in header:
field, to_field = header.split('.', 1)
headers[field] = to_field