Skip to content

Instantly share code, notes, and snippets.

@rebeccawilliams
Created September 24, 2013 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebeccawilliams/6692591 to your computer and use it in GitHub Desktop.
Save rebeccawilliams/6692591 to your computer and use it in GitHub Desktop.
csv sorting for crime data
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