Python, geopy time limit raising -
i'm totally beginner @ python, need bit help. use geopy in long loop in python, service timed out error. code following:
#!/usr/bin/python # -*- coding: utf-8 -*- import os, sys geopy.geocoders import nominatim geopy.exc import geocodertimedout geolocator = nominatim() fobj_out = open('out.txt', 'a') open('alagridsor.txt') fobj_in: koor in fobj_in: koor.rstrip() location = geolocator.reverse(koor, timeout=none) cim = location.raw['address']['country'] print(cim) fobj_out.write(cim.encode('utf8')) fobj_out.write("\n") fobj_out.close()
and read method function, maybe work, don't know how implement code. function is:
def do_geocode(address): try: return geopy.geocode(address) except geocodertimedout: return do_geocode(address)
can me in this?
Comments
Post a Comment