1

I am trying to add a new key called Country. My main problem is to convert the location into Country. The Users from Stackoverflow can write everything and it has no format. I have tried geopy but it doesn't detect some countries for Russia or Tokyo as a state.

The second problem is that geopy doesn't allow many requests. I have around 8 million Users.

That Code is just an edit version:

def geopytesting(testing, user):
    from geopy import Nominatim
    
    try:
        geolocator = Nominatim()
        location2 = geolocator.geocode(testing)
        print(location2.address)
    except BaseException:
        print("Error")

geopytesting("Russia",None)
geopytesting("Hamburg",None)
geopytesting("Madrid",None)
geopytesting("Omaha",None)
geopytesting("Berlin",None)
geopytesting("Schleswig-Holzstein",None)
geopytesting("Asyż",None)
geopytesting("",None)
geopytesting("Tilted Tower",None)

I hope you can Help me. I really try many things and I haven't seen a post which handle this specific problem. Either it detect some countries or I get kicked out because I made too many requests.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
JoshED
  • 33
  • 2
  • 1
    For starters, don't call `geopy` for every value. Your app should have/build a sizeable map of strings to locations -- bonus points of you use machine learning. This will greatly cut down on the requests needed to geopy. – Brock Adams May 15 '18 at 18:16
  • Have you any source or example for me? – JoshED May 17 '18 at 15:39

0 Answers0