From bd8943f36afce771942da39dd283cddbe69548f3 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Sun, 21 Mar 2021 19:47:02 +0200 Subject: [PATCH] csv_metadata_quality/app.py: Don't crash if fields are missing We don't need to crash if someone feeds us a CSV file that is miss- ing commont DSpace fields like title, type, and subject. --- csv_metadata_quality/app.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/csv_metadata_quality/app.py b/csv_metadata_quality/app.py index 5a02680..82e6e1c 100644 --- a/csv_metadata_quality/app.py +++ b/csv_metadata_quality/app.py @@ -164,13 +164,16 @@ def run(argv): # Check: duplicate items # We extract just the title, type, and date issued columns to analyze - duplicates_df = df.filter( - regex=r"dcterms\.title|dc\.title|dcterms\.type|dc\.type|dcterms\.issued|dc\.date\.issued" - ) - check.duplicate_items(duplicates_df) + try: + duplicates_df = df.filter( + regex=r"dcterms\.title|dc\.title|dcterms\.type|dc\.type|dcterms\.issued|dc\.date\.issued" + ) + check.duplicate_items(duplicates_df) - # Delete the temporary duplicates DataFrame - del duplicates_df + # Delete the temporary duplicates DataFrame + del duplicates_df + except IndexError: + pass ## # Perform some checks on rows so we can consider items as a whole rather