Created
January 4, 2011 20:02
-
-
Save eyeseast/765314 to your computer and use it in GitHub Desktop.
Get every nomination vote since the 107th Congress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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