Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError: 'charmap' codec can't decode #178

Closed
jlluch opened this issue Jul 9, 2019 · 1 comment
Closed

UnicodeDecodeError: 'charmap' codec can't decode #178

jlluch opened this issue Jul 9, 2019 · 1 comment
Labels

Comments

@jlluch
Copy link

jlluch commented Jul 9, 2019

Hi,
I am using a repository with multiple files, and parsing fails with some files:

gpx = gpxpy.parse(gpxfile)

File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\gpxpy_init_.py", line 36, in parse
parser = mod_parser.GPXParser(xml_or_file)

File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\gpxpy\parser.py", line 58, in init
self.init(xml_or_file)

File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\gpxpy\parser.py", line 70, in init
text = xml_or_file.read() if hasattr(xml_or_file, 'read') else xml_or_file

File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\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 0x9d in position 609: character maps to

I don't know how to read these files, Any ideas??
Thx in advance.

@tkrajina tkrajina added the bug label Jul 27, 2019
@tomsix
Copy link

tomsix commented Jun 4, 2020

I had the same issue but solved it by adding the file encoding

file = open('your-file', encoding='utf-8')
gpx = gpx.parse(file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants