geopy
このオブジェクトの出力をファイルに書き込もうとしていcsv
ますが、各文字が別の列に配置され、緯度と経度が別の行に出力されます。どうすれば修正できますか?
この関数を別の時間に実行して、新しいアドレスを次の行に出力できるようにしたいと考えています。データを上書きせずに保存します。csv
これは Pythonでの書き込みで実行できますか?
from geopy.geocoders import Nominatim
import csv
def loc_find(file):
'''
This function take in a user given location and gives back the address with
city, zip code, state, county and country.
It also provides latitude and longitude.
'''
geolocator = Nominatim()
loc_input = raw_input("Add the location you would like data back for: ")
location = geolocator.geocode(loc_input)
print(location.address)
print((location.latitude, location.longitude))
with open(r"", 'w') as fp:
a = csv.writer(fp)
data = location
a.writerows(data)