diff --git a/CHANGELOG.md b/CHANGELOG.md index 649af24..60a038c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `dcterms.bibliographicCitation` fields - Fixed regex so we run the comma space fix on `dcterms.bibliographicCitation` fields +- Don't crash the country/region checker/fixer when a title field is missing ### Changed - Don't run newline fix on description fields diff --git a/csv_metadata_quality/check.py b/csv_metadata_quality/check.py index 7f2d34b..ccf8378 100755 --- a/csv_metadata_quality/check.py +++ b/csv_metadata_quality/check.py @@ -563,8 +563,13 @@ def countries_match_regions(row, exclude): un_region = cc.convert(names=country, to="UNRegion") if un_region != "not found" and un_region not in regions: - print( - f"{Fore.YELLOW}Missing region ({country} → {un_region}): {Fore.RESET}{row[title_column_name]}" - ) + try: + print( + f"{Fore.YELLOW}Missing region ({country} → {un_region}): {Fore.RESET}{row[title_column_name]}" + ) + except KeyError: + print( + f"{Fore.YELLOW}Missing region ({country} → {un_region}): {Fore.RESET}