Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created October 5, 2013 16:37
Show Gist options
  • Save mrchrisadams/6843082 to your computer and use it in GitHub Desktop.
Save mrchrisadams/6843082 to your computer and use it in GitHub Desktop.
Example of generating CSV files from python
from csv import writer
from random import randint, uniform
# count reported thefts
with open('theft.csv', 'wb') as f:
w = writer(f)
w.writerow(['type', 'lat', 'lng'])
w.writerows(["sanitation",
str(uniform(32.303634, 32.281359)),
str(uniform(36.318525, 36.34007))]
for _ in range(500))
# count reported sanitation incidents
with open('sanitation.csv', 'wb') as f:
w = writer(f)
w.writerow(['type', 'lat', 'lng'])
w.writerows(["sanitation",
str(uniform(32.303634, 32.281359)),
str(uniform(36.318525, 36.34007))]
for _ in range(500))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment