Skip to content

Commit

Permalink
import_csv: my try so error is actually caught
Browse files Browse the repository at this point in the history
  • Loading branch information
dale-wahl committed Dec 20, 2023
1 parent 0049de6 commit f3e01ea
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions datasources/upload/import_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ def process(self):

# pseudonymise or anonymise as needed
filtering = self.parameters.get("pseudonymise")
if filtering:
for field, value in item.items():
if field is None:
raise ValueError("Field is None") # This would normally be caught when writerow is called
if field.startswith("author"):
if filtering == "anonymise":
item[field] = "REDACTED"
elif filtering == "pseudonymise":
item[field] = hash_cache.update_cache(value)

try:
if filtering:
for field, value in item.items():
if field is None:
raise ValueError("Field is None") # This would normally be caught when writerow is called
if field.startswith("author"):
if filtering == "anonymise":
item[field] = "REDACTED"
elif filtering == "pseudonymise":
item[field] = hash_cache.update_cache(value)

writer.writerow(item)
except ValueError as e:
self.dataset.log(f"Error ({e}) writing item {i}: {item}")
Expand Down

0 comments on commit f3e01ea

Please sign in to comment.