Skip to content

Instantly share code, notes, and snippets.

@erichannell
Created April 25, 2018 21:26
Show Gist options
  • Save erichannell/911b361f316dfaaa729d7e82f9d0d621 to your computer and use it in GitHub Desktop.
Save erichannell/911b361f316dfaaa729d7e82f9d0d621 to your computer and use it in GitHub Desktop.
convert lat and lon data from takeout.google.com into addresses
import reverse_geocoder as rg
import csv
with open("output.csv", 'w') as outf:
writer = csv.writer(outf)
writer.writerow(['index', 'lat', 'lon', 'datetime', 'country', 'location', 'area1', 'area2''])
with open("input.csv", 'r') as inf:
reader = csv.reader(inf)
reader.next()
for row in reader:
coordinates = (float(row[1]), float(row[2]))
results = rg.search(coordinates)
results = results[0]
place = results['name']
country_code = results['cc']
row.append([country_code, place, results['admin1'], results['admin2']])
writer.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment