Created
October 5, 2013 16:37
-
-
Save mrchrisadams/6843082 to your computer and use it in GitHub Desktop.
Example of generating CSV files from python
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
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