Skip to content

Commit

Permalink
Handle None value for years
Browse files Browse the repository at this point in the history
  • Loading branch information
wrridgeway committed Jan 21, 2025
1 parent 1f29902 commit 718c151
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion socrata/socrata_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
).cursor(unload=True)


def parse_years(years):
"""
Make sure the years environmental variable is formatted correctly.
"""

if years is not None:
years = str(years).replace(" ", "").split(",")

return years


def get_asset_info(socrata_asset):
"""
Simple helper function to retrieve asset-specific information from dbt.
Expand Down Expand Up @@ -352,6 +363,6 @@ def socrata_upload(
socrata_upload(
socrata_asset=os.getenv("SOCRATA_ASSET"),
overwrite=os.getenv("OVERWRITE"),
years=str(os.getenv("YEARS")).replace(" ", "").split(","),
years=parse_years(os.getenv("YEARS")),
by_township=os.getenv("BY_TOWNSHIP"),
)

0 comments on commit 718c151

Please sign in to comment.