Skip to content

Instantly share code, notes, and snippets.

@andygarfield
Last active February 7, 2016 01:09
Show Gist options
  • Save andygarfield/b936915044ed9cb245d0 to your computer and use it in GitHub Desktop.
Save andygarfield/b936915044ed9cb245d0 to your computer and use it in GitHub Desktop.
Pythonista GPS logger
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