Read JSON file correctly

Peter Otten __peter__ at web.de
Sat Apr 1 08:43:05 EDT 2017


Umar Yusuf wrote:

> How do I read this json file correctly? Details at:
> 
> http://stackoverflow.com/questions/43152368/python-unicodedecodeerror-charmap-codec-cant-decode-byte-0x81-in-position

Should you ever come back please take the time to post the "details" here. 
Also, provide the traceback as text rather than an image. 
Thank you.

As the answer on stackoverflow says, the file is opened using the cp1252 
encoding when it should be utf-8.

While I don't know how to make that the default on Windows here's a 
workaround:

import pandas

with open("input.json", encoding="utf-8") as infile:
    df = pandas.read_json(infile)



More information about the Python-list mailing list