[GH-ISSUE #140] [Espn] Postponed matches raise KeyError: 'roster' #29

Closed
opened 2026-03-02 15:55:10 +03:00 by kerem · 2 comments
Owner

Originally created by @jerem1e on GitHub (Jan 8, 2023).
Original GitHub issue: https://github.com/probberechts/soccerdata/issues/140

I am using python Python 3.11.1 and soccerdata 1.3.1.

When trying to read the matchsheet of a game that was postponed the package raises a KeyError 'roster'

I tried to read the matchseet for this game:
AFC Bournemouth-Brighton vs Hove Albion on 2022-09-10 with the gameid 637887
And it raised:

KeyError                                  Traceback (most recent call last)
/Users/jeremie/projects/spitch/scrap_bundesliga/get_teamdata.py in line 2
      13 # %%
----> 14 main('ENG-Premier League', '../data/premier_league_games.csv')

/Users/jeremie/projects/spitch/scrap_bundesliga/get_teamdata.py in line 7, in main(league, output_path)
      6 espn = sd.ESPN(leagues=league, seasons=2223)
      8 schedule = espn.read_schedule()
----> 10 games = espn.read_matchsheet(match_id=schedule['game_id'])
      12 games.to_csv(output_path, index=False)

File ~/Library/Caches/pypoetry/virtualenvs/scrap-bundesliga-kR_91-RR-py3.11/lib/python3.11/site-packages/soccerdata/espn.py:201, in ESPN.read_matchsheet(self, match_id)
    186 data = json.load(reader)
    187 for i in range(2):
    188     match_sheet = {
    189         'game': match['game'],
    190         'league': match['league'],
    191         'season': match['season'],
    192         'team': data['boxscore']['form'][i]['team']['displayName'],
    193         'is_home': (i == 0),
    194         'venue': data['gameInfo']['venue']['fullName']
    195         if 'venue' in data['gameInfo']
    196         else None,
    197         'attendance': data['gameInfo']['attendance'],
...
    202     }
    203     if 'statistics' in data['boxscore']['teams'][i]:
    204         for stat in data['boxscore']['teams'][i]['statistics']:

KeyError: 'roster'

Here is the example code I used:

import soccerdata as sd

espn = sd.ESPN('ENG-Premier League', '2223')

game = espn.read_matchsheet([637887])
Originally created by @jerem1e on GitHub (Jan 8, 2023). Original GitHub issue: https://github.com/probberechts/soccerdata/issues/140 I am using python Python 3.11.1 and soccerdata 1.3.1. When trying to read the matchsheet of a game that was postponed the package raises a KeyError 'roster' I tried to read the matchseet for this game: AFC Bournemouth-Brighton vs Hove Albion on 2022-09-10 with the gameid `637887` And it raised: ``` KeyError Traceback (most recent call last) /Users/jeremie/projects/spitch/scrap_bundesliga/get_teamdata.py in line 2 13 # %% ----> 14 main('ENG-Premier League', '../data/premier_league_games.csv') /Users/jeremie/projects/spitch/scrap_bundesliga/get_teamdata.py in line 7, in main(league, output_path) 6 espn = sd.ESPN(leagues=league, seasons=2223) 8 schedule = espn.read_schedule() ----> 10 games = espn.read_matchsheet(match_id=schedule['game_id']) 12 games.to_csv(output_path, index=False) File ~/Library/Caches/pypoetry/virtualenvs/scrap-bundesliga-kR_91-RR-py3.11/lib/python3.11/site-packages/soccerdata/espn.py:201, in ESPN.read_matchsheet(self, match_id) 186 data = json.load(reader) 187 for i in range(2): 188 match_sheet = { 189 'game': match['game'], 190 'league': match['league'], 191 'season': match['season'], 192 'team': data['boxscore']['form'][i]['team']['displayName'], 193 'is_home': (i == 0), 194 'venue': data['gameInfo']['venue']['fullName'] 195 if 'venue' in data['gameInfo'] 196 else None, 197 'attendance': data['gameInfo']['attendance'], ... 202 } 203 if 'statistics' in data['boxscore']['teams'][i]: 204 for stat in data['boxscore']['teams'][i]['statistics']: KeyError: 'roster' ``` Here is the example code I used: ```python import soccerdata as sd espn = sd.ESPN('ENG-Premier League', '2223') game = espn.read_matchsheet([637887]) ```
kerem 2026-03-02 15:55:10 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@jerem1e commented on GitHub (Jan 12, 2023):

@probberechts hey I saw that you fixed it, but there is no new version? I am using the latest GitHub version now, but was wondering when this will be released to pypi.

<!-- gh-comment-id:1380639635 --> @jerem1e commented on GitHub (Jan 12, 2023): @probberechts hey I saw that you fixed it, but there is no new version? I am using the latest GitHub version now, but was wondering when this will be released to pypi.
Author
Owner

@probberechts commented on GitHub (Jan 13, 2023):

Now 😃

<!-- gh-comment-id:1382120031 --> @probberechts commented on GitHub (Jan 13, 2023): Now :smiley:
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/soccerdata#29
No description provided.