Skip to content

Commit

Permalink
removed dumb temp steps
Browse files Browse the repository at this point in the history
  • Loading branch information
dannguyen committed Aug 13, 2015
1 parent 31bf3bc commit 0a1ddc4
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions scripts/83.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
# The sum of White House staffermember salaries in 2014
# Note: this is a pretty verbose step-by-step
import requests
import csv
url = "https://open.whitehouse.gov/api/views/i9g8-9web/rows.csv?accessType=DOWNLOAD"
txt = requests.get(url).text
# save the file temporarily
f = open("/tmp/salaries2014.csv", "w")
f.write(txt)
f.close()
###
# reopen (yes, this is wasteful, but whatever)
f = open("/tmp/salaries2014.csv", "r")
rows = list(csv.DictReader(f))
totes = 0
for r in rows:
for r in csv.DictReader(txt.splitlines()):
# remove $ sign, convert to float
salval = float(r['Salary'].replace('$', ''))
totes += salval

print(totes)

# 37776925.0

0 comments on commit 0a1ddc4

Please sign in to comment.