Skip to content

Instantly share code, notes, and snippets.

@eyeseast
Created January 4, 2011 20:02
Show Gist options
  • Select an option

  • Save eyeseast/765314 to your computer and use it in GitHub Desktop.

Select an option

Save eyeseast/765314 to your computer and use it in GitHub Desktop.
Get every nomination vote since the 107th Congress
#!/usr/bin/env python
# encoding: utf-8
"""
Get every nomination vote since the 107th Congress
"""
import csv
import sys
import os
from nytcongress import NytCongress
nyt = NytCongress()
def main():
with open('nom_votes.csv', 'wb') as f:
writer = csv.DictWriter(f, fieldnames=[
'congress', 'description', 'result',
'date', 'yes', 'no', 'present', 'not_voting'
])
writer.writerow(dict(zip(writer.fieldnames, writer.fieldnames)))
for congress in range(107, 112):
votes = nyt.votes.nominations(congress)['votes']
for vote in votes:
row = {
'congress' : congress,
'description' : vote['description'],
'result' : vote['result'],
'date' : vote['date'],
'yes' : vote['total']['yes'],
'no' : vote['total']['no'],
'present' : vote['total']['present'],
'not_voting' : vote['total']['not_voting']
}
writer.writerow(row)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment