1
0
mirror of https://github.com/ilri/csv-metadata-quality.git synced 2025-05-11 07:36:01 +02:00

Don't crash when title is missing

We shouldn't crash the country/region checker/fixer when the title
field is missing, since we only use it to show status to the user.
This commit is contained in:
2023-06-12 10:33:50 +03:00
parent 1fa81f7558
commit f3fb1ff7fb
3 changed files with 20 additions and 6 deletions

View File

@ -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}<title field not present>"
)
return