Skip to content

Instantly share code, notes, and snippets.

Created July 15, 2017 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e228a0122c250a149ce64813f8da6e09 to your computer and use it in GitHub Desktop.
Save anonymous/e228a0122c250a149ce64813f8da6e09 to your computer and use it in GitHub Desktop.
latlong = { "latitude": latitude,"longitude": longitude}
if os.stat(filepath).st_size==0: //check to see if file has been created if not, write first line.
with open(filepath, 'w') as outfile:
json.dump(latlong, outfile)
else:
with open(filepath, mode='r+') as feedsjson: //this is where the file is meant to be appended.
feeds = json.load(feedsjson)
newdata = (latlong)
feeds.update(newdata)
json.dump(feeds, feedsjson)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment