Python 2.6 を使用して、はるか下のスクリプトを実行すると、次のエラーが発生します。
Traceback (most recent call last):
File "g.py", line 7, in <module>
results = Geocoder.geocode(row[0])
File "/usr/lib/python2.6/site-packages/pygeocoder.py", line 261, in geocode
return GeocoderResult(Geocoder.getdata(params=params))
File "/usr/lib/python2.6/site-packages/pygeocoder.py", line 223, in getdata
raise GeocoderError(j['status'], url)
pygeocoder.GeocoderError: Error ZERO_RESULTS
Query: http://maps.google.com/maps/api/geocode/json?region=&sensor=false&bounds=&language=&address=%22++A+FAKE+ADDRESS
Python 2.6 スクリプト:
import csv, string
from pygeocoder import Geocoder
with open('file.csv') as goingGeo:
theSpreadsheet = csv.reader(goingGeo, quotechar=None)
for row in theSpreadsheet:
results = Geocoder.geocode(row[0])
(lat, long) = results[0].coordinates
with open('geo_file.csv', 'a') as f:
f.write(row[0] + ",")
f.write(row[1] + ",")
f.write(row[2] + ",")
f.write(row[3] + ",")
f.write(row[4] + ",")
f.write(row[5] + ",")
f.write(row[6] + ",")
f.write(row[7] + ",")
try:
f.write(str(lat))
except GeocoderError:
pass
f.write(",")
try:
f.write(str(long))
except GeocoderError:
pass
f.write('\n')
エラーが発生してもスクリプトを続行したいだけです。
ありがとうございました!