python - Import CSV NBA Stats in Excel -
so after struggling long time i've found way data nba.com in comma separated values
how nice csv or excel file? or better if possible, how can automatically query data web querying table through excel web query?
the following should started:
import requests import csv url = "http://stats.nba.com/stats/leaguedashplayerstats?datefrom=&dateto=&gamescope=&gamesegment=&lastngames=15&leagueid=00&location=&measuretype=advanced&month=0&opponentteamid=0&outcome=&paceadjust=n&permode=totals&period=0&playerexperience=&playerposition=&plusminus=n&rank=n&season=2015-16&seasonsegment=&seasontype=regular+season&starterbench=&vsconference=&vsdivision=" data = requests.get(url) entries = data.json() open('output.csv', 'wb') f_output: csv_output = csv.writer(f_output) csv_output.writerow(entries['resultsets'][0]['headers']) csv_output.writerows(entries['resultsets'][0]['rowset'])
this produce output.csv
file starting follows:
player_id,player_name,team_id,team_abbreviation,age,gp,w,l,w_pct,min,off_rating,def_rating,net_rating,ast_pct,ast_to,ast_ratio,oreb_pct,dreb_pct,reb_pct,tm_tov_pct,efg_pct,ts_pct,usg_pct,pace,pie,fgm,fga,fgm_pg,fga_pg,fg_pct,cfid,cfparams 201166,aaron brooks,1610612741,chi,31.0,13,6,7,0.462,17.5,105.8,106.8,-0.9,0.243,2.4,25.9,0.015,0.077,0.046,10.8,0.5,0.511,0.198,95.84,0.065,36,85,2.8,6.5,0.424,5,"201166,1610612741" 203932,aaron gordon,1610612753,orl,20.0,15,3,12,0.2,23.0,98.9,106.4,-7.5,0.1,1.91,15.7,0.089,0.228,0.158,8.2,0.575,0.608,0.151,94.16,0.124,46,87,3.1,5.8,0.529,5,"203932,1610612753" 1626151,aaron harrison,1610612766,cha,21.0,7,3,4,0.429,4.2,103.3,95.4,7.9,0.0,0.0,0.0,0.08,0.08,0.08,16.7,0.0,0.0,0.095,100.22,-0.032,0,5,0.0,0.7,0.0,5,"1626151,1610612766"
Comments
Post a Comment