I currently have a list of files. I am aiming to sort the data into separate arrays.
The data is similar to the following content repeated many times.
[
{
"private": {
"bankroll": 1000,
"last_bid": 0,
"launching": false,
"name": "abc",
"tech": 0
},
"public": {
"auction_round": 0,
"game_stage": "start",
"last_mining_payoff": 0,
"last_winning_bid": 0,
"last_winning_bidders": [],
"last_winning_miner": "",
"max_rounds": 201,
"players": {
"AggressiveLauncher": {
"bankroll": 1000
},
"abc": {
"bankroll": 1000
},
"PassiveLauncher": {
"bankroll": 1000
},
"def": {
"bankroll": 1000
},
"SpongeBob": {
"bankroll": 1000
}
},
"round": 0
}
}, ...]
Code snippet,
for a in range(len(abc_files)):
temp=str(abc_files[a])
path='designated path'
print(path)
with open(path, "r") as b:
lines = json.load(b)
lines=str(lines)
lines=lines.replace("\'","\"")
print(lines)
list_temp=json.loads(lines)
for i in range(len(list_temp)):
bankroll.append(list_temp[i]['private']['bankroll'])
print(bankroll)
Whenever it runs, I am currently generating an error for the list_temp=json.loads(lines) line. The error is as follows list_temp=json.loads(lines)
File "C:\Users\abc\anaconda3\lib\json_init_.py", line 357, in loads return _default_decoder.decode(s)
File "C:\Users\abc\anaconda3\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\abc\anaconda3\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None JSONDecodeError: Expecting value
The data is already as a string too, it was the first thing I attempted.
list_temp=json.loads(lines)- bherbruck