我正在尝试读取geohhes的CSV文件,并将其转换为经/纬度。我正在使用Python的Geohash模块。这是我的代码:
import Geohash
import csv
with open('C:\Users\Data\myData.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
geoHash = row[0]
print(str(geoHash)) #This prints sucessfully
geoStr = str(geoHash)
Geohash.decode(geoStr) #This fails
该代码仅在最后一行失败,geoStr
成功输出了每个geohash。我收到的错误是:
Traceback (most recent call last):
文件
"C:/Users/PycharmProjects/GeoHash/GeoHash_to_LatLong.py", line 11, in <module>
Geohash.decode(geoStr)
File "C:\Users\PycharmProjects\GeoHash\venv\lib\site-packages\Geohash\geohash.py", line 68, in decode
lat, lon, lat_err, lon_err = decode_exactly(geohash)
File "C:\Users\PycharmProjects\GeoHash\venv\lib\site-packages\Geohash\geohash.py", line 44, in decode_exactly
cd = __decodemap[c]
KeyError: 'o'
我已经检查了CSV,似乎没有任何奇数字符或任何会导致失败的字符。有什么想法吗?