Skip to content

Commit

Permalink
Merge tag '2023-03-30_csv_report' into develop
Browse files Browse the repository at this point in the history
Improve output to CSV ingest
  • Loading branch information
Steven-Eardley committed Mar 30, 2023
2 parents d262b08 + e09f2af commit 8e01aa4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion portality/crosswalks/journal_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ def _unfurl_apc(x):
apcs = []
for apc in x.split('; '):
[amt, cur] = apc.split()
apcs.append({'apc_max': round(float(amt)), 'apc_currency': cur})
apcs.append({'apc_currency': cur, 'apc_max': round(float(amt))})
apcs.reverse()
return apcs

# Undo the transformations applied to specific fields. TODO: Add these as they are encountered in the wild
Expand Down
13 changes: 11 additions & 2 deletions portality/scripts/journals_update_via_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,14 @@
else:
print('\nSkipping CSV headings check.\n')

# Talking about spreadsheets, so we start at 1
row_ix = 1

# ~~ ->$JournalUpdateByCSV:Feature ~~
for row in reader:
row_ix += 1
print(f'\n***\nCSV row {row_ix}')

# Skip empty rows
if not any(row.values()):
print("Skipping empty row.")
Expand Down Expand Up @@ -132,7 +138,7 @@
continue

if j is not None:
print('\n' + j.id)
print('Updating journal with ID ' + j.id)
# Load remaining rows into application form as an update
# ~~ ^->JournalQuestions:Crosswalk ~~
update_form, updates = journal_questions.Journal2QuestionXwalk.question2form(j, row)
Expand Down Expand Up @@ -215,7 +221,10 @@
if alock is not None:
alock.delete()
else:
print("No updates to do")
updates = ['NO CHANGES']
else:
print("\nWARNING: no journal found for ID {0}".format(_id))
print("WARNING: no journal found for ID {0}".format(_id))
writer.writerow([_id, "NOT FOUND", ''])

writer.writerow([j.id, ' | '.join(updates), ''])

0 comments on commit 8e01aa4

Please sign in to comment.