Skip to content

Instantly share code, notes, and snippets.

@sanchi
Created July 22, 2015 23:29
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 sanchi/f304e0c0d2739ba2f2bd to your computer and use it in GitHub Desktop.
Save sanchi/f304e0c0d2739ba2f2bd to your computer and use it in GitHub Desktop.
from nominatim import Nominatim
import time
n = Nominatim()
outf = open('geos.txt', 'w')
with open('adrs.txt') as inputfile:
for line in inputfile:
print line
o = n.query("Berlin, "+line)
if len(o) > 0:
try:
lat = o[0]['lat']
lon = o[0]['lon']
print line + " -> " +lat+";"+lon
outf.write(lat+";"+lon+"\n")
time.sleep(1)
except:
print "?;?"
outf.write("?;?\n")
else:
print "?;?"
outf.write("?;?\n")
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment