0

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.

1 Answer 1

0

I think this would solve the problem

with open(path_to_json_file, "r") as f:
   data = json.load(f)
2
  • i get the same error with this adaptation
    – MaartenRo
    Commented Jul 26, 2023 at 12:13
  • Did you try with 'rb' instead of 'r'. Once I had also faced the same situation but I was able to resolve it following this method. Commented Jul 26, 2023 at 12:30

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.