Last active
February 7, 2016 01:09
-
-
Save andygarfield/b936915044ed9cb245d0 to your computer and use it in GitHub Desktop.
Pythonista GPS logger
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 location | |
import time | |
import datetime | |
location.start_updates() | |
loc = location.get_location() | |
last_loc = '{0},{1}\n'.format(loc['latitude'], loc['longitude']) | |
print(last_loc) | |
for seconds in range(1800): | |
loc = location.get_location() | |
lat_long = '{0},{1},{2}\n'.format(loc['latitude'], loc['longitude'], datetime.datetime.utcnow()) | |
if lat_long != last_loc: | |
print(lat_long) | |
with open('log.csv', 'a') as log: | |
log.write(lat_long) | |
last_loc = lat_long | |
time.sleep(5) | |
location.stop_updates() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment