Can someone help me figure out why I am receiving the error message.
Phyton code:
import json
import csv
with open("/Users/olicaluag/Desktop/capture_for_BRONEK_FILTER.txt") as file:
data = json.load(file)
fname = “oli_bronek.csv”
with open(fname, “w”) as file:
csv_file = csv.writer(file)
csv_file.writerow([“Jitter”, “Latency”, “Link”, “Packetloss”, “Timestamp”])
for result in data[“logs”]:
csv_file.writerow([item[“jitter”], item[“latency”], item[“link”], item[“packetloss”], item[“timestamp”]])
Error message received after running the code:
data = json.load(file)
File “/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/init.py”, line 293, in load
return loads(fp.read(),
File “/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/init.py”, line 346, in loads
return _default_decoder.decode(s)
File “/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py”, line 340, in decode
raise JSONDecodeError(“Extra data”, s, end)
json.decoder.JSONDecodeError: Extra data: line 5 column 30 (char 190)
json file looks like this:
{
“interface”: “port1”,
“logs”: ,
“name”: “Default_FortiGuard”
},
{
“interface”: “port1”,
“logs”: [
{
“jitter”: 0.073233,
“latency”: 15.612933,
“link”: “up”,
“packetloss”: 0,
“timestamp”: 1624284672
},
{
“jitter”: 0.069133,
“latency”: 15.622801,
“link”: “up”,
“packetloss”: 0,
“timestamp”: 1624284672
},
{
“jitter”: 0.059133,
“latency”: 15.622666,
“link”: “up”,
“packetloss”: 0,
“timestamp”: 1624284673
},
{
“jitter”: 0.059000,
“latency”: 15.621200,
“link”: “up”,
“packetloss”: 0,
“timestamp”: 1624284673
},
{
“jitter”: 0.055633,
“latency”: 15.623632,
“link”: “up”,
“packetloss”: 0,
“timestamp”: 1624284674
},
{
“jitter”: 0.054100,
“latency”: 15.624532,
“link”: “up”,
“packetloss”: 0,
“timestamp”: 1624284674
},
{
“jitter”: 0.165400,
“latency”: 15.660831,
“link”: “up”,
“packetloss”: 0,
“timestamp”: 1624285272
}
.
.
.
.
],
“name”: “bronek”
},