Hello all,
I want to export json data file into excel in terms of loop code I wrote in the below.
football.json
{
"results": [
{
"leagues": [
{
"matches": [
{
"league": "Premier League",
"teams": "Liverpool - Chelsea",
"score": [
"3:0"
]
},
{
"league": "Premier League",
"teams": "Man Utd - Arsenal",
"score": [
"2:1"
]
}
]
},
{
"matches": [
{
"league": "La Liga",
"teams": "Atletico Madrid - Villareal",
"score": [
"0:2"
]
}
]
}
]
}
]
}
football.py:
import json
with open("football.json") as f:
jsondata = json.load(f)
for a in jsondata["results"][0]["leagues"]:
for b in a["matches"]:
if "Liverpool" in b["teams"] or "La Liga" in b["league"]:
continue
print(b["league"],b["teams"],b["score"][0])
output:
Premier League Man Utd - Arsenal 2:1
I want to have this output in excel file in this format
Premier League,Man Utd - Arsenal,2:1