NBA Stats goes back to the 1946-47 Season, but game level statistics were introduced over time. For example, NBA Stats does not show 3 Point Field Goals for the 1946-47 season as that stat was first recorded at the game level in the 1979-1980 season.
- Nba Download Game Logs Csv To Word
- Free Nba Download Game
- Nba Download Game Logs Csv To Excel
- Nba Download Game Logs Csv 2017
- Nba Download Game Logs Csv Free
Nba Download Game Logs Csv To Word
Free Nba Download Game
######################################################################### |
## Get NBA Team Game Logs From the Stattleship API |
######################################################################### |
## install and load the stattleshipR package |
devtools::install_github('stattleship/stattleship-r') |
library(stattleshipR) |
## set API token |
set_token('YOUR_ACCESS_TOKEN') |
## set up envt |
options(stringsAsFactors=FALSE) |
## set params |
sport<-'basketball' |
league<-'nba' |
ep<-'team_game_logs' |
## leave q_body empty to get all |
## or set for specific team or dates |
## set season_id |
q_body<-list(season_id='nba-2015-2016') |
## get the team game logs |
nba_team_gls<- ss_get_result(sport=sport, league=league, ep=ep, query=q_body, version=1, verbose=TRUE, walk=TRUE) |
## bind together data |
tgls<- lapply(nba_team_gls, function(x) x$team_game_logs) |
team_game_logs<- do.call('rbind', tgls) |
team_game_logs<- rbindlist(tgls) |
## team game log data cleanup |
team_game_logs$coach_technical_fouls[which(is.na(team_game_logs$coach_technical_fouls))] <-0 |
team_game_logs$points_biggest_lead[which(is.na(team_game_logs$points_biggest_lead))] <-0 |
team_game_logs$technical_fouls[which(is.na(team_game_logs$technical_fouls))] <-0 |
## add team details |
teams<- lapply(team_game_logs, function(x) x$teams) |
all_teams<- do.call('rbind', teams) |
the_teams<-all_teams[match(team_game_logs$team_id, all_teams$id),] |
team_game_logs$team_slug<-the_teams[match(team_game_logs$team_id, the_teams$id),]$slug |
team_game_logs$opponent_slug<-the_teams[match(team_game_logs$opponent_id, the_teams$id),]$slug |
## add game details |
games<- lapply(games, function(x) x$games) |
the_games<- do.call('rbind', games) |
the_games<-the_games[match(team_game_logs$game_id, the_games$id),] |
team_game_logs$scoreline<-the_games[match(team_game_logs$game_id, the_games$id),]$scoreline |
team_game_logs$winning_team_id<-the_games[match(team_game_logs$game_id, the_games$id),]$winning_team_id |
team_game_logs$score_differential<-the_games[match(team_game_logs$game_id, the_games$id),]$score_differential |
team_game_logs$game_started_at<-the_games[match(team_game_logs$game_id, the_games$id),]$started_at |
team_game_logs$game_ended_at<-the_games[match(team_game_logs$game_id, the_games$id),]$ended_at |
team_game_logs$game_slug<-the_games[match(team_game_logs$game_id, the_games$id),]$slug |
So after struggling a long time I've found a way to get the data from nba.com in comma separated values
This is the result 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=
How do I get that into a nice CSV or excel file?Or even better if possible, how can I automatically query this data like web querying a table through excel web query?
Matt1 Answer
The following should get you started:
This would produce an output.csv
file starting as follows: