Skip to content

Commit

Permalink
fix: sanitize city null
Browse files Browse the repository at this point in the history
  • Loading branch information
lubojr committed Oct 20, 2023
1 parent eca56e1 commit 1c183cb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions generators/generate_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,14 @@ def handle_GeoDB_endpoint(config, endpoint, data, catalog):
city = unique_values["city"]
if country not in countries:
countries.append(country)
if city not in cities:
cities.append(city)
# sanitize city identifier to be sure it is filename save
city = "".join([c for c in city if c.isalpha() or c.isdigit() or c==' ']).rstrip()
if city is not None:
city = "".join([c for c in city if c.isalpha() or c.isdigit() or c==' ']).rstrip()
# Additional check to see if city name is empty afterwards
if city == "":
if city == "" or city is None:
city = "undefined"
if city not in cities:
cities.append(city)
min_date = min(times)
max_date = max(times)
latlon = unique_values["aoi"]
Expand Down

0 comments on commit 1c183cb

Please sign in to comment.