BurntSushi/nflgame

Player Position Error

Closed this issue · 3 comments

I wrote some code last season that was working great. however when I go to run it this season I am getting an error. The code is supposed to pull a few player stats based on which position they play. Here is my code:


week = 1
games = nflgame.games(2017, week)
play = nflgame.combine_plays(games)

path = "C:\\Users\\ccooper\\Documents\\nfl\\Current\\WRDepth\\Incomplete\\Week"  + str(week)+".csv"
w = csv.writer(open(path, 'wb'))
w.writerow(["Name", "Team", "Position", "Yds"])

for play in play.filter(passing_incmp__gt=0):
    for player in play.players:
        if player.player.position in ['WR', 'TE', 'RB']:
            row = [player, player.player.team, player.player.position,  play.passing_incmp_air_yds] 
            w.writerow(row)

and my error is:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 11, in <module>
AttributeError: 'NoneType' object has no attribute 'position'

Any help with this would be much appreciated!!!

so I have noticed when I run the update_players.pyc utility it does not replace the existing players.json...

The update schedule utility does replace the schedule.json

Also in the players.json located on the gitHub pull, it is also missing the team and position field.

followed advice from Jay Deluca at bottom of the page and fixed the error - #316