Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
executable file 50 lines (35 sloc) 1.4 KB
#!/usr/bin/env python
from geopy import geocoders
import csv
import keys
_BING_API = keys.bing_api
g = geocoders.GoogleV3()
b = geocoders.Bing(_BING_API, timeout=60)
with open('./data/entartete_kunst_full_14FEB2014.csv', 'rb') as file:
r = csv.reader(file)
w = csv.writer(open('./data/entartete_kunst_geocoded_bing2.csv', 'w'))
header =
header.extend(['lat', 'lng'])
unknown = 0
no_res = 0
total = 0
success = 0
for row in r:
total += 1
results = b.geocode(row[6], exactly_one=False)
if row[6] != 'NA' and row[6] != 'unbekannt':
if results:
place, (lat, lng) = results[0]
row.extend([str(lat), str(lng)])
print total, "- adding for %s - %.5f, %.5f" % (row[6], lat, lng)
success += 1
no_res += 1
print total, '- no results for: ', row[6]
unknown += 1
print total, '- location is unknown: ', row[6]
print 'All Done! Total Geocodes: %i, Unknown: %i, Successfully Geocoded: %i, No Results: %i' % (total, unknown, success, no_res)
print 'Success rate today = ', round(float(success)/float(total)*100), '%'