3

I'm trying to import a JSON file in python but I keep running into an error

with open('e:\0_1export.json', 'r') as f:
data = f.read().strip();

Error message:

ValueError                                Traceback (most recent call last)
<ipython-input-40-abd9cb3a729a> in <module>()
----> 1 with open('e:\0_1export.json', 'r') as f:
  2     data = f.read().strip();

ValueError: embedded null character

Here is the pastebin of the contents of the file i am trying to import .

https://pastebin.com/mCZiPktJ

Any help is appreciated!

Abhinav H
  • 31
  • 1
  • 1
  • 4

1 Answers1

11

'e:\0_1export.json' must be written as 'e:\\0_1export.json' or r'e:\0_1export.json'. Otherwise, Python treats '\0' as a NULL character (the character with the code 0).

DYZ
  • 55,249
  • 10
  • 64
  • 93