Created
September 24, 2013 23:10
-
-
Save rebeccawilliams/6692591 to your computer and use it in GitHub Desktop.
csv sorting for crime data
This file contains 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
import csv | |
massive = open("socrata.csv") | |
crimedata = open("crimedata.csv", 'w') | |
read_file = csv.reader(massive) | |
write_file = csv.writer(crimedata) | |
Crime = 0 | |
Public_Safety = 0 | |
for line in read_file: | |
if line[5].strip() == 'Crime': | |
Crime += 1 | |
write_file.writerow(line) | |
if line[5].strip() == 'Public Safety': | |
Public_Safety += 1 | |
write_file.writerow(line) | |
print "There are %s Crime datasets and %s Public Safety datasets on Socrata portals as of June 2013" % (Crime, Public_Safety) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment