I am trying to run a Python script using Geopy that creates a list of coordinates. I have installed Geopy, and am running from Terminal on a Mac.
python
from geopy import geocoders
import csv
g_api_key = 'I HAVE ENTERED MY GOOGLE API HERE’
g = geocoders.Google(g_api_key)
I then get the error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Google'
Could my API key be wrong? Why is this happening? If I didn't receive this message, I would load the .csv next:
costcos = csv.reader(open('costcos-limited.csv'), delimiter=',')
next(costcos) #skip header
#print header
print "Address,City,State,Zip Code,Latitude,Longitude"
continue
full_addy = row[1] + "," + row[2] + "," + row[3] + "," + row[4]
try:
place, (lat, lng) = list(g.geocode(full_addy, exactly_one=False))[0]
print full_addy + "," + str(lat) + "," + str(lng)
except:
print full_addy + ",NULL,NULL"
Is this code correct, and is the 'continue' (above 'full_addy') necessary in this code? Finally, if I get help to make the 'geocoders.Google' work, and this script works, how do you run a Python script? I.e. I've been writing these commands into Terminal, how do I run the script on the final 'print full_addy + ",NULL,NULL"' line and save the output as costcos-geocoded.csv?
Thank you in advance for any help that comes my way...