Created
April 25, 2018 21:26
-
-
Save erichannell/911b361f316dfaaa729d7e82f9d0d621 to your computer and use it in GitHub Desktop.
convert lat and lon data from takeout.google.com into addresses
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 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