ValueError when using pandas.read_json
I had the same error message, and I solved it by using an absolute path.
import os
basePath = os.path.dirname(os.path.abspath(__file__))
df = pandas.read_json(basePath + '/ut1.json', orient = 'records', dtype={"A":str, "B":list})
That worked for me!
In my case, the path was wrong.
Make sure you check your current working directory, by placing this just before the pandas.read_json
:
import os
print(os.getcwd())
After tried @learn2day's answer, I still cannot get a good result from there, but I do try the following code and everything works for me. (PS: I'm opening a JSON file where Chinese characters were UTF-8 characters appeared - Chinese characters)
pandas.read_json(open("ut1.json", "r", encoding="utf8"))
The encoding="utf8"
is the key part of this code.