API-FOOTBALL

FREEMIUM
Verified
Durch API-SPORTS | Aktualisiert hace 8 días | Sports
Popularität

10 / 10

Latenz

365ms

Service Level

99%

Health Check

N/A

Zurück zu allen Diskussionen

Iterating over JSON data and printing. (or creating Pandas DataFrame from JSON file)

Rapid account: Ckelleher Bektqav Qm
ckelleher-BektqavQm
hace 2 años

Hello - I’m trying to print specific values from the JSON file that I pulled using API-Football using the /players functionality. From what I understand, I am pulling it as a JSON file that has a list of dictionaries of players, with a nested dictionary for each player containing their data (i.e. name, team, etc.).

I’m running into issues printing the values within the ‘player’ dictionary, as each character is printing on a separate line.

The end result I am trying to get to is a Pandas DataFrame containing all the values from the JSON file, but I can’t even seem to iterate through the JSON file correctly.

Here is my code:

url = "https://api-football-v1.p.rapidapi.com/v3/players"

querystring = {"league":"39","season":"2020", "page":"2"}

headers = {
		"X-RapidAPI-Host": "api-football-v1.p.rapidapi.com",
		"X-RapidAPI-Key": "xxxxxkeyxxxxx"

}

response = requests.request("GET", url, headers=headers, params=querystring).json()

response_dump = json.dumps(response)

for item in response_dump:
	for player_item in item:
		print(player_item)

Nehmen Sie an der Diskussion teil - fügen Sie unten einen Kommentar hinzu:

Anmelden / Registrieren, um neue Kommentare zu veröffentlichen