Skip to content

Instantly share code, notes, and snippets.

@Yousuf28
Last active August 27, 2019 15:43
Show Gist options
  • Save Yousuf28/6361d34501c8e0945c509b004f951ce7 to your computer and use it in GitHub Desktop.
Save Yousuf28/6361d34501c8e0945c509b004f951ce7 to your computer and use it in GitHub Desktop.
AI for drug discovery article
#import library
from googlegeocoder import GoogleGeocoder
# put your key
geocoder = GoogleGeocoder("your key")
# create csv file to save latitude and longitude
csv_file = open('start_up_ai.csv', 'ab')
writer = csv.writer(csv_file, dialect='excel', delimiter=',', encoding='utf-8')
writer.writerow(['lat', 'lng'])
df_address = df_add['address']
# address that does not work save into list
no_lat =[]
for k in df_address:
try:
search = geocoder.get(k)
lat = search[0].geometry.location.lat
lng = search[0].geometry.location.lng
writer.writerow([lat, lng])
except:
no_lat.append(k)
pass
csv_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment