FantasyFootballAnalytics / FantasyFootballAnalyticsR

R scripts and data files for the Fantasy Football Analytics website
http://fantasyfootballanalytics.net/
447 stars 1.58k forks source link

Error when adding new site #34

Closed sansbacon closed 4 years ago

sansbacon commented 7 years ago

Here is the code I'm using to add the rotoworld projection file that I downloaded:

# sites
sites = rbind(sites, list(21, "Rotoworld", 1, "NA"))

# analysts
analysts = rbind(analysts, list(30, "Rotoworld", 21, 1, 0, "NA", 0.428))

# analystPositions
analystPositions = rbind(analystPositions, list(233, 30, 1, 0, "QB"), list(233, 30, 1, 0, "RB"), list(233, 30, 1, 0, "WR"), list(233, 30, 1, 0, "TE"))

# siteUrls
siteUrls = rbind(siteUrls, list(21, "/rotoworld/rotoworld_{$Season}_{$WeekNo}.csv")

# siteTables
rbind(siteTables, list(175, "QB", 21, 1, 1, 1, 1, 0, "QB"), list(176, "RB", 21, 1, 1, 1, 1, 0, "RB"), list(177, "WR", 21, 1, 1, 1, 1, 0, "WR"), list(178, "TE", 21, 1, 1, 1, 1, 0, "TE"))

# dataColumns
# start at 251
lrow = max(dataColumns$dataColId)
dataColumns = rbind(dataColumns, list(lrow+1, "player", "character"), 
      list(lrow+2, "pos", "character"),
      list(lrow+3, "team", "character"),
      list(lrow+4, "g", "numeric"),
      list(lrow+5, "pass_yds", "numeric"),
      list(lrow+6, "pass_td", "numeric"),
      list(lrow+7, "pass_int", "numeric"),
      list(lrow+8, "rush_yds", "numeric"),
      list(lrow+9, "rush_td", "numeric"),
      list(lrow+10, "rec_yds", "numeric"),
      list(lrow+11, "rec_td", "numeric"),
      list(lrow+12, "fpts", "numeric"))

# tableColumns
# tableId, columnName, columnType, columnOrder, columnPeriod, removeColumn
# rotoworld tableIds 175-qb, 176-rb, 177-wr, 178-te
# datacolumnids 251-262
# player 251, pos 252, team 253, g 254, pass_yds 255, pass_td 256, pass_int 257,
# rush_yds 258, rush_td 259, rec_yds 260, rec_td 261, fpts 262
tableColumns = rbind(tableColumns, 
      list(175, "player", "character", 1, "season", 0),
      list(175, "pos", "character", 2, "season", 0),
      list(175, "team", "character", 3, "season", 0),
      list(175, "g", "numeric", 4, "season", 0),
      list(175, "pass_yds", "numeric", 5, "season", 0),
      list(175, "pass_td", "numeric", 6, "season", 0),
      list(175, "pass_int", "numeric", 7, "season", 0),
      list(175, "rush_yds", "numeric", 8, "season", 0),
      list(175, "rush_td", "numeric", 9, "season", 0),
      list(175, "rec_yds", "numeric", 10, "season", 0),
      list(175, "rec_td", "numeric", 11, "season", 0),
      list(175, "fpts", "numeric", 12, "season", 0),
      list(176, "player", "character", 1, "season", 0),
      list(176, "pos", "character", 2, "season", 0),
      list(176, "team", "character", 3, "season", 0),
      list(176, "g", "numeric", 4, "season", 0),
      list(176, "pass_yds", "numeric", 5, "season", 0),
      list(176, "pass_td", "numeric", 6, "season", 0),
      list(176, "pass_int", "numeric", 7, "season", 0),
      list(176, "rush_yds", "numeric", 8, "season", 0),
      list(176, "rush_td", "numeric", 9, "season", 0),
      list(176, "rec_yds", "numeric", 10, "season", 0),
      list(176, "rec_td", "numeric", 11, "season", 0),
      list(176, "fpts", "numeric", 12, "season", 0),
      list(177, "player", "character", 1, "season", 0),
      list(177, "pos", "character", 2, "season", 0),
      list(177, "team", "character", 3, "season", 0),
      list(177, "g", "numeric", 4, "season", 0),
      list(177, "pass_yds", "numeric", 5, "season", 0),
      list(177, "pass_td", "numeric", 6, "season", 0),
      list(177, "pass_int", "numeric", 7, "season", 0),
      list(177, "rush_yds", "numeric", 8, "season", 0),
      list(177, "rush_td", "numeric", 9, "season", 0),
      list(177, "rec_yds", "numeric", 10, "season", 0),
      list(177, "rec_td", "numeric", 11, "season", 0),
      list(177, "fpts", "numeric", 12, "season", 0),
      list(178, "player", "character", 1, "season", 0),
      list(178, "pos", "character", 2, "season", 0),
      list(178, "team", "character", 3, "season", 0),
      list(178, "g", "numeric", 4, "season", 0),
      list(178, "pass_yds", "numeric", 5, "season", 0),
      list(178, "pass_td", "numeric", 6, "season", 0),
      list(178, "pass_int", "numeric", 7, "season", 0),
      list(178, "rush_yds", "numeric", 8, "season", 0),
      list(178, "rush_td", "numeric", 9, "season", 0),
      list(178, "rec_yds", "numeric", 10, "season", 0),
      list(178, "rec_td", "numeric", 11, "season", 0),
      list(178, "fpts", "numeric", 12, "season", 0)
)

# see if it works
scrapeData <- runScrape(week = 0, season = 2016, analysts = c(-1, 5, 7, 18, 27, 30), positions = c("QB", "RB", "WR", "TE"))

This produces the following output:

Retrieving player data 
Error in if (dataType %in% c("file", "csv") & urlSite != "fantasysharks") { : 
  argument is of length zero

Do you have any suggestions about the source of the error? I've attached an excerpt of the csv file.

rotoworld_2016_0.txt

isaactpetersen commented 4 years ago

See the latest version of the app here: https://github.com/FantasyFootballAnalytics/ffanalytics