mirror of
https://github.com/ilri/csv-metadata-quality.git
synced 2024-11-22 05:45:02 +01:00
csv_metadata_quality/fix.py: fix bug in regions
We need to make sure we're only manipulating the regions if we have any missing. The previous code was always manipulating the existing row, even when there were no missing regions, which resulted in new values like "Eastern Africa||".
This commit is contained in:
parent
7ce20726d0
commit
f49214fa2e
@ -369,14 +369,15 @@ def countries_match_regions(row):
|
|||||||
)
|
)
|
||||||
missing_regions.append(un_region)
|
missing_regions.append(un_region)
|
||||||
|
|
||||||
# Add the missing regions back to the row, paying attention to whether
|
if len(missing_regions) > 0:
|
||||||
# or not the row's region column is None (aka null) or just an empty
|
# Add the missing regions back to the row, paying attention to whether
|
||||||
# string (length would be 0).
|
# or not the row's region column is None (aka null) or just an empty
|
||||||
if row[region_column_name] is not None and len(row[region_column_name]) > 0:
|
# string (length would be 0).
|
||||||
row[region_column_name] = (
|
if row[region_column_name] is not None and len(row[region_column_name]) > 0:
|
||||||
row[region_column_name] + "||" + "||".join(missing_regions)
|
row[region_column_name] = (
|
||||||
)
|
row[region_column_name] + "||" + "||".join(missing_regions)
|
||||||
else:
|
)
|
||||||
row[region_column_name] = "||".join(missing_regions)
|
else:
|
||||||
|
row[region_column_name] = "||".join(missing_regions)
|
||||||
|
|
||||||
return row
|
return row
|
||||||
|
Loading…
Reference in New Issue
Block a user