Created
July 10, 2014 13:18
-
-
Save tdgunes/920b76a4d84244bf541b to your computer and use it in GitHub Desktop.
Test data generator
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
# !/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
geo_test_gen.py | |
~~~~~~~~~~ | |
Author: Taha Dogan Gunes | |
""" | |
import json | |
def ask(): | |
while True: | |
try: | |
lat = float(raw_input("Lat: ")) | |
lon = float(raw_input("Lon: ")) | |
comment = raw_input("Comment: ") | |
return {"lat":lat,"lon":lon,"comment":comment} | |
except KeyboardInterrupt: | |
return | |
except: | |
print "Wrong input type!" | |
continue | |
def main(): | |
with open("test.json", "a") as f, open('test_wc.json', 'a') as g: | |
while True: | |
data = ask() | |
if data: | |
g.write(json.dumps(data)+"\n") | |
data.pop("comment",None) | |
f.write(json.dumps(data)+"\n") | |
else: | |
break | |
if __name__ == '__main__': | |
print "Control-C to Exit&Save" | |
main() | |
print "Files saved as test.json and test_wc.json, wc is not WC :)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment