Skip to content

Commit

Permalink
download fars data
Browse files Browse the repository at this point in the history
  • Loading branch information
theja committed Aug 28, 2023
1 parent cecc919 commit aa39eb2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions general/update_fars/01_download_fars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from urllib import request
import os

# place to save data locally
data_folder = "/mnt/c/Users/tputta/OneDrive - Toole Design/Desktop/SSPF/FARS"

start_yr = 2015
end_yr = 2021

for yr in range(start_yr, end_yr+1):
print(f"Downloading {yr} FARS data")
if not os.path.exists(f"{data_folder}/{yr}"):
os.mkdir(f"{data_folder}/{yr}")
request.urlretrieve(f"https://static.nhtsa.gov/nhtsa/downloads/FARS/{yr}/National/FARS{yr}NationalCSV.zip", f"{data_folder}/{yr}/FARS{yr}NationalCSV.zip")
yr += 1

0 comments on commit aa39eb2

Please sign in to comment.