Skip to content

Commit

Permalink
Merge branch 'hotfix/2023-03-31_case_insensitive_csv_ingest'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven-Eardley committed Mar 31, 2023
2 parents e09f2af + b195e00 commit f3b670a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions portality/crosswalks/journal_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def q2idx(cls, ident):
ident = cls.DEGEN[ident]
i = 0
for k, q in cls.QTUP:
if k == ident:
if k.lower() == ident.lower():
return i
i += 1
return -1
Expand All @@ -94,10 +94,10 @@ def p(cls, ident):
""" p is a backwards q - i.e. get the question from the CSV heading """
if ident in cls.DEGEN.values():
for k, v in cls.DEGEN.items():
if ident == v:
if ident.lower() == v.lower():
ident = k
for k, q in cls.QTUP:
if q == ident:
if q.lower() == ident.lower():
return k
return None

Expand Down
10 changes: 10 additions & 0 deletions portality/scripts/journals_update_via_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@
# verify header row with current CSV headers, report errors
header_row = reader.fieldnames
expected_headers = JournalFixtureFactory.csv_headers()

# Always perform a match check on supplied headers, not counting order
for h in header_row[1:]:
if h not in expected_headers:
if h.lower() in map(str.lower, expected_headers):
(print(f'\nNOTE - "{h}" has mismatching case to expected header, but changes should succeed.'))
else:
print(f'\nWARNING - Unexpected header "{h}" not mappable (updates will be missed)')

# Strict check for CSV being exactly the same as exported, including order
if not args.skip_strict:
if header_row[1:] != expected_headers:
print("\nWARNING: CSV input file is the wrong format. "
Expand Down

0 comments on commit f3b670a

Please sign in to comment.