Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
json decoding error
#4
try this

import json
import datetime
import pandas as pd
list=[]

# combine json
files=['1.json', '2.json', '3.json', '4.json', '5.json']

result = []
for f in files:
    with open(f, "r") as infile:
        result.append(json.load(infile))

with open("12.json", "w") as outfile:
    json.dump(result, outfile)


# make xlsx
with open("12.json", encoding="UTF-8") as f:
    jsondata = json.load(f)
    
for data in jsondata:
    if "items" in data:
        for matches in data["items"]:
            if "Alternative" in matches["champName"]:
                continue
            list.append([matches["champName"],datetime.datetime.fromtimestamp(matches["dateStart"]),matches["opp1"],matches["opp2"],matches["score"]])
df=pd.DataFrame(list)
df.to_excel("output.xlsx")
print("Saved.")
Reply


Messages In This Thread
json decoding error - by deneme2 - Mar-19-2023, 12:54 PM
RE: json decoding error - by rob101 - Mar-19-2023, 01:16 PM
RE: json decoding error - by deneme2 - Mar-21-2023, 12:38 PM
RE: json decoding error - by Axel_Erfurt - Mar-21-2023, 05:37 PM
RE: json decoding error - by deneme2 - Mar-22-2023, 12:14 PM
RE: json decoding error - by Axel_Erfurt - Mar-22-2023, 04:40 PM
RE: json decoding error - by deneme2 - Mar-22-2023, 05:21 PM
RE: json decoding error - by Axel_Erfurt - Mar-22-2023, 05:36 PM
RE: json decoding error - by deneme2 - Mar-22-2023, 08:09 PM
RE: json decoding error - by deanhystad - Mar-22-2023, 10:44 PM
RE: json decoding error - by Axel_Erfurt - Mar-22-2023, 08:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Decoding lat/long in file name johnmcd 4 448 Mar-22-2024, 11:51 AM
Last Post: johnmcd
  json loads throwing error mpsameer 8 811 Jan-23-2024, 07:04 AM
Last Post: deanhystad
  Enigma Decoding Problem krisarmstrong 4 848 Dec-14-2023, 10:42 AM
Last Post: Larz60+
  python requests library .JSON() error mHosseinDS86 6 3,590 Dec-19-2022, 08:28 PM
Last Post: deanhystad
  Read nested data from JSON - Getting an error marlonbown 5 1,470 Nov-23-2022, 03:51 PM
Last Post: snippsat
  flask app decoding problem mesbah 0 2,403 Aug-01-2021, 08:32 PM
Last Post: mesbah
  Decoding a serial stream AKGentile1963 7 8,862 Mar-20-2021, 08:07 PM
Last Post: deanhystad
  JSON Decode error when using API to create dataframe Rubstiano7 4 3,021 Jan-11-2021, 07:52 PM
Last Post: buran
  Empty response to request causing .json() to error t4keheart 1 10,195 Jun-26-2020, 08:35 PM
Last Post: bowlofred
  empty json file error mcmxl22 1 10,289 Jun-17-2020, 10:20 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020