reverse_geocode
reverse_geocode copied to clipboard
'charmap' codec error
We have installed the tool for python 3.9 on a Windows 10 pc and tested it with the example, but it don't work. See error message below:
raceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\huete\PycharmProjects\BigData\venv\lib\site-packages\reverse_geocode\__init__.py", line 121, in search
gd = GeocodeData()
File "C:\Users\huete\PycharmProjects\BigData\venv\lib\site-packages\reverse_geocode\__init__.py", line 25, in getinstance
instances[cls] = cls()
File "C:\Users\huete\PycharmProjects\BigData\venv\lib\site-packages\reverse_geocode\__init__.py", line 34, in __init__
coordinates, self.locations = self.extract(rel_path(geocode_filename))
File "C:\Users\huete\PycharmProjects\BigData\venv\lib\site-packages\reverse_geocode\__init__.py", line 100, in extract
for latitude, longitude, country_code, city in rows:
File "C:\Users\huete\AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 464: character maps to <undefined>
The problem seems to be with csv.reader. Manually adding the encoding parameter to init.py seems to solve the problem. For example:
rows = csv.reader(open(local_filename, encoding='utf-8'))
I added PR https://github.com/richardpenman/reverse_geocode/pull/10 to fix it.
This encoding parameter is now added.