I’m new to python, I used the below code in spyder platform to parse the json file but it reflects an error.
JavaScript
x
6
1
import json
2
3
with open('D:/Py_Scrach/used_car_prices1.json') as f:
4
data = json.load(f)
5
print(data)
6
Error:
JavaScript
1
17
17
1
runfile('C:/Users/sathishkumar.m/.spyder-py3/temp.py', wdir='C:/Users/sathishkumar.m/.spyder-py3')
2
Traceback (most recent call last):
3
4
File "C:Userssathishkumar.m.spyder-py3temp.py", line 10, in <module>
5
data = json.load(f)
6
7
File "C:ProgramDataAnaconda3libjson__init__.py", line 293, in load
8
return loads(fp.read(),
9
10
File "C:ProgramDataAnaconda3libjson__init__.py", line 346, in loads
11
return _default_decoder.decode(s)
12
13
File "C:ProgramDataAnaconda3libjsondecoder.py", line 340, in decode
14
raise JSONDecodeError("Extra data", s, end)
15
16
JSONDecodeError: Extra data
17
Advertisement
Answer
df1 = pd.read_json(“D:/Py_Scrach/used_car_prices1.json”,lines=True)