forked from stanfordjournalism/search-script-scrape
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path80.py
More file actions
20 lines (19 loc) · 591 Bytes
/
Copy path80.py
File metadata and controls
20 lines (19 loc) · 591 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# The total number of babies named Odin born in Colorado according to the Social Security Administration
import shutil
import requests
url = 'http://www.ssa.gov/OACT/babynames/state/namesbystate.zip'
# Downloading will take awhile...
print("Downloading", url)
resp = requests.get(url)
# save to hard drive
with open("/tmp/ssastates.zip", "wb") as f:
f.write(resp.content)
# unzip
shutil.unpack_archive("/tmp/ssastates.zip", "/tmp")
# open up the file
rows = open("/tmp/CO.TXT").readlines()
totes = 0
for r in rows:
if 'Odin' in r:
totes += int(r.split(',')[4])
print(totes)