Skip to content

Commit

Permalink
add param checks to hdx_dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio9701 committed Aug 21, 2024
1 parent 285f2b8 commit d461ef5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion urbanpy/download/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,14 @@ def hdx_dataset(resource):
stacklevel=2,
)

hdx_url = f"https://data.humdata.org/dataset/{resource}"
if not resource.ends_with(".csv"):
raise AttributeError("This function only expects a CSV file.")

if not resource.starts_with("https://data.humdata.org/dataset/"):
hdx_url = f"https://data.humdata.org/dataset/{resource}"
else:
hdx_url = hdx_url

dataset = pd.read_csv(hdx_url)

return dataset

0 comments on commit d461ef5

Please sign in to comment.