Convert the JSON data on NBAs Site to easy to use CSV format!
How to get JSON data:
- Go to the stats.nba.com
- Select a page of particular statistics you might want (example: http://stats.nba.com/players/isolation/)
- Right click on the page, then select inspect
- On the new box that popped on on the right of the screen, select the Network tab
- Under the network bar, select XHR, then there should be a link that says something like "leaguedashplayer" 5a. If you don't see it, refresh the page
- Click it, and copy the "Request URL" into another tab
- Save the data to a .json file
- You're done!
How to convert JSON to CSV
- Save the jsoncsv.py script into a folder
- Save the JSON dataset(s) into the same folder as the script
- Open terminal, and make the directory the folder all the datafiles and scripts are in
- For each file, type "python3 jsoncsv.py jsonfile", with jsonfile being the file name
- A new csv file with the same name as the json file should be in the folder
- You're done!
- If you get an error using the jsoncsv.py script, try the jsoncsv_cluster.py script. For sets that are clustered (like shooting stats split by distance), the original script may not work.