MaartenRo
MaartenRo

Reputation: 1

error message json conversion to excel in python

I am trying to convert a json file into an excel file in Python. With this code i try to convert a json file to an Excel file:

json_file: data = json.load(json_file) ```

I get an error message relating to the last line of code:

Traceback (most recent call last): File "<pyshell#37>", line 2, in data = json.load(json_file) File "C:\Users\Maarten Rodik\Desktop\Lib\json_init_.py", line 293, in load return loads(fp.read(), File "C:\Users\Maarten Rodik\Desktop\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 0x8f in position 12364: character maps to

With another json file the script worked, so i guess the problem has to do with the file. How can i solve this? i tried the same code with another json file and it worked.

Upvotes: 0

Views: 62

Answers (1)

Suman Gaire
Suman Gaire

Reputation: 44

I think this would solve the problem

with open(path_to_json_file, "r") as f:
   data = json.load(f)

Upvotes: 0

Related Questions