vishaalagartha / basketball_reference_scraper

A python module for scraping static and dynamic content from Basketball Reference.
MIT License
254 stars 91 forks source link

get_all_star_box_score(2012) returns error #70

Closed rudiejd closed 2 years ago

rudiejd commented 2 years ago

Attempting to get the box score for the 2012 all-star game returns an error about out of range indexing for a player's last name

Code to reproduce:

from basketball_reference_scraper.box_score import get_all_star_box_score

print(get_all_star_box_score(2012))
Traceback (most recent call last):
  File "/home/jd/git/basketball_reference_scraper/test/test_box_scores.py", line 25, in test_get_all_star_box_score
    d = get_all_star_box_score(2012)
  File "/home/jd/git/basketball_reference_scraper/basketball_reference_scraper/box_scores.py", line 88, in get_all_star_box_score
    stats_df = get_stats(dnp, ask_matches=False)
  File "/home/jd/git/basketball_reference_scraper/basketball_reference_scraper/players.py", line 14, in get_stats
    suffix = get_player_suffix(name)
  File "/home/jd/git/basketball_reference_scraper/basketball_reference_scraper/utils.py", line 90, in get_player_suffix
    initial = last_name_part[0].lower()
IndexError: string index out of range
rudiejd commented 2 years ago

Looks like this is because get_player_suffix('Joe Johnson') is not working. Not sure if this worked before, but right now it's broken because makes a blank last name part of the suffix