Created By Kevin Edmond
Repository for Python NBA Player API to CSV Script: Extract NBA player data and format into a CSV File
-
Install Python 3 for your system using instructions here.
-
Install required packages.
command:
python3 pip install requests -
Run the script.
command:
python3 nba_players.py
-
Use the RapidAPI API python template to make initial API call and retrieve data
-
Create
total_pagesandpagevariables to manage pagination in returned player data. -
Create a CSV file with column headers,
'player id #','first name','last name','position', and'team name', to store specific player data. -
Run a
while loopthat continues to run untilpageequalstotal_pages. Inside of this loop afor loopwill iterate through the page of returned data adding the specific fields of data as a row in the CSV file. Once the page of data is complete, the API call variables,page,querystring,response, andplayer_listare updated for the subsequent page API call. -
A notification regarding the CSV creation is displayed.