# Verify that we can open and read the election results CSV correctly
# Print out all the state names from the csv # Coded in the "object-oriented" style from electiondata import ElectionResults filename = '2012_US_election_state.csv' results = ElectionResults(filename) results.load() print "Opened file:" # state_names = results.states() # for state in state_names: # print " "+state obama = results.get_votes("obama") romney = results.get_votes("romney") print " The number of votes for Obama across all states are: "+str(obama) print " The number of votes for Romney across all states are: "+str(romney)