Open ToddAtWSU opened 7 years ago
Okay, so I tried running it a couple more times and got this far. Any idea how to fix this error?:
418/428 complete. (97.66%) 419/428 complete. (97.90%) 420/428 complete. (98.13%) 421/428 complete. (98.36%) 422/428 complete. (98.60%) 423/428 complete. (98.83%) 424/428 complete. (99.07%) 425/428 complete. (99.30%) 426/428 complete. (99.53%) 427/428 complete. (99.77%) 428/428 complete. (100.00%) Done!
There were some errors during the download. Usually this is a result of an HTTP request timing out, which means the resulting "players.json" file is probably missing some data. An appropriate solution is to re-run the script until there are no more errors (or when the errors are problems on NFL.com side.)
Could not get player info from roster row:
72 Leno, Charles, Jr. T ACT 6'3" 305 10/9/1991 4 Boise State Exception:
Traceback (most recent call last): File "C:\Python27\lib\site-packages\nflgame\update_players.py", line 419, in run roster.append(meta_from_soup_row(team, row)) File "C:\Python27\lib\site-packages\nflgame\update_players.py", line 179, in meta_from_soup_row last_name, first_name = map(lambda s: s.strip(), name.split(',')) ValueError: too many values to unpack
Exact same error I get, no matter how many times I run it.
This is a bandaid fix... but will let you get past the problem.
Edit update_players.py
After line 175 add these two lines: if name.count(',') == 2: name = name.strip(', Jr.')
Make sure to match the spacing...
Before: def meta_from_soup_row(team, soup_row): tds, data = [], [] for td in soup_row.find_all('td'): tds.append(td) data.append(td.get_text().strip()) profile_url = 'http://www.nfl.com%s' % tds[1].a['href']
name = tds[1].a.get_text().strip()
if ',' not in name:
last_name, first_name = name, ''
else:
last_name, first_name = map(lambda s: s.strip(), name.split(','))
return {
'team': team,
'profile_id': profile_id_from_url(profile_url),
'profile_url': profile_url,
'number': try_int(data[0]),
After:
def meta_from_soup_row(team, soup_row): tds, data = [], [] for td in soup_row.find_all('td'): tds.append(td) data.append(td.get_text().strip()) profile_url = 'http://www.nfl.com%s' % tds[1].a['href']
name = tds[1].a.get_text().strip()
if name.count(',') == 2:
name = name.strip(', Jr.')
if ',' not in name:
last_name, first_name = name, ''
else:
last_name, first_name = map(lambda s: s.strip(), name.split(','))
return {
'team': team,
'profile_id': profile_id_from_url(profile_url),
'profile_url': profile_url,
'number': try_int(data[0]),
Not sure if this will help you, but I found that installing nflgame via github solved the problem for me:
pip uninstall nflgame
pip install git+https://github.com/BurntSushi/nflgame.git
And then running the player update script finally worked without error. I've done this successfully on mac and linux but not PC, so not sure if helps.
chedder123 I did the bandaid fix to get around the Jr. issue and it seems to have worked. However, I received errors opening the file with gedit (see below) - did this cause a major issue? Should I uninstall/reinstall?
[root@blackhouse nflgame]# gedit update_player.py (gedit:6498): WARNING : Error when getting information for file '/usr/lib/python2.7/site-packages/nflgame/update_player.py': No such file or directory
(gedit:6498): WARNING : Set document metadata failed: Setting attribute metadata::gedit-position not supported [root@blackhouse nflgame]# gedit update_players.py
(gedit:6514): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
(gedit:6514): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
(gedit:6514): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
(gedit:6514): WARNING : Set document metadata failed: Setting attribute metadata::gedit-spell-language not supported
(gedit:6514): WARNING : Set document metadata failed: Setting attribute metadata::gedit-encoding not supported
(gedit:6514): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
(gedit:6514): WARNING : Set document metadata failed: Setting attribute metadata::gedit-spell-language not supported
(gedit:6514): WARNING : Set document metadata failed: Setting attribute metadata::gedit-encoding not supported ^C [root@blackhouse nflgame]# python update_players.py Loading games for POST 2016 week 5 Downloading team rosters... 32/32 complete. (100.00%) Done!
Ran into this issue with player Charles Leno Jr.
I read this post after "fixing" the issue myself.
Instead of using
if name.count(',') == 2:
name = name.strip(', Jr.')
I used
if ", Jr." in name:
name = name.replace(", Jr.", "")
same result either way.... it's the extra comma in there that is the problem.
Why doesn't any other NFL player have a Jr. in their name on nfl.com like Odell?
So I remembered I need to update the player information before getting stats for rookies and the such. So I successfully ran pip to install the upgrade to nflgame. I couldn't get nflgame-update-players to run through Powershell or the command window in Windows 10, but I did load the script in Idle with Python 2.7. I hit Run to execute the script and got the following output:
What do I need to do to get this to run completely? Or am I doing something incorrectly? Thanks again for your help!