We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 655d4f6 commit 9f23886Copy full SHA for 9f23886
usafacts/delphi_usafacts/pull.py
@@ -25,9 +25,10 @@ def fetch(url: str, cache: str) -> pd.DataFrame:
25
"""
26
r = requests.get(url)
27
r.raise_for_status()
28
- filename = os.path.join(
29
- cache,
30
- f"{date.today().strftime('%Y%m%d')}_{url.replace(r'.*/','')}.csv")
+ datestamp = date.today().strftime('%Y%m%d')
+ name = url.split('/')[-1].replace('.csv','')
+ os.makedirs(cache, exist_ok=True)
31
+ filename = os.path.join(cache, f"{datestamp}_{name}.csv")
32
with open(filename, "w") as f:
33
f.write(r.text)
34
return pd.read_csv(filename)
0 commit comments