[GH-ISSUE #193] [FBref] Not specifying leagues results in a 'Big 5 European Leagues Combined' KeyError #43

Closed
opened 2026-03-02 15:55:17 +03:00 by kerem · 1 comment
Owner

Originally created by @Kalaweksh on GitHub (Mar 27, 2023).
Original GitHub issue: https://github.com/probberechts/soccerdata/issues/193

When an FBref object is initialized with the default leagues parameter, the titular error is thrown on calling FBref,read_schedule(). It looks like this is because the LEAGUE_DICT constant in _config.py does not have an entry by default for that key. Edit: Inserting 'Big 5 European Leagues' to LEAGUE_DICT prevents an error from being thrown, but results in the wrong table being scraped.

The error is not thrown when FBref is initialized with, for instance, a list of the big 5 instead of None.

Originally created by @Kalaweksh on GitHub (Mar 27, 2023). Original GitHub issue: https://github.com/probberechts/soccerdata/issues/193 When an FBref object is initialized with the default leagues parameter, the titular error is thrown on calling FBref,read_schedule(). It looks like this is because the LEAGUE_DICT constant in _config.py does not have an entry by default for that key. Edit: Inserting 'Big 5 European Leagues' to LEAGUE_DICT prevents an error from being thrown, but results in the wrong table being scraped. The error is not thrown when FBref is initialized with, for instance, a list of the big 5 instead of None.
kerem 2026-03-02 15:55:17 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@probberechts commented on GitHub (Mar 29, 2023):

This is the full error:


In [1]: import soccerdata as sd
In [2]: fbref = sd.FBref(seasons="2223")
/cw/dtaijupiter/NoCsBack/dtai/pieterr/Projects/soccerdata/soccerdata/fbref.py:94: UserWarning: You are trying to scrape data for all of the Big 5 European leagues. This can be done more efficiently by setting leagues='Big 5 European Leagues Combined'.
  warnings.warn(
In [3]: fbref.read_schedule()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-f65eaed055e7> in <module>
----> 1 fbref.read_schedule()

/cw/dtaijupiter/NoCsBack/dtai/pieterr/Projects/soccerdata/soccerdata/fbref.py in read_schedule(self, force_cache)
    474             url_fixtures = FBREF_API + tree.xpath("//a[text()='Scores & Fixtures']")[0].get("href")
    475             filepath_fixtures = self.data_dir / f"schedule_{lkey}_{skey}.html"
--> 476             current_season = not self._is_complete(lkey, skey)
    477             reader = self.get(
    478                 url_fixtures, filepath_fixtures, no_cache=current_season and not force_cache

/cw/dtaijupiter/NoCsBack/dtai/pieterr/Projects/soccerdata/soccerdata/_common.py in _is_complete(self, league, season)
    260             flip = {v: k for k, v in self._all_leagues().items()}
    261             if league in flip:
--> 262                 league_dict = LEAGUE_DICT[flip[league]]
    263             else:
    264                 raise ValueError(f"Invalid league '{league}'")

KeyError: 'Big 5 European Leagues Combined'
<!-- gh-comment-id:1488412236 --> @probberechts commented on GitHub (Mar 29, 2023): This is the full error: ```py In [1]: import soccerdata as sd In [2]: fbref = sd.FBref(seasons="2223") /cw/dtaijupiter/NoCsBack/dtai/pieterr/Projects/soccerdata/soccerdata/fbref.py:94: UserWarning: You are trying to scrape data for all of the Big 5 European leagues. This can be done more efficiently by setting leagues='Big 5 European Leagues Combined'. warnings.warn( In [3]: fbref.read_schedule() --------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-3-f65eaed055e7> in <module> ----> 1 fbref.read_schedule() /cw/dtaijupiter/NoCsBack/dtai/pieterr/Projects/soccerdata/soccerdata/fbref.py in read_schedule(self, force_cache) 474 url_fixtures = FBREF_API + tree.xpath("//a[text()='Scores & Fixtures']")[0].get("href") 475 filepath_fixtures = self.data_dir / f"schedule_{lkey}_{skey}.html" --> 476 current_season = not self._is_complete(lkey, skey) 477 reader = self.get( 478 url_fixtures, filepath_fixtures, no_cache=current_season and not force_cache /cw/dtaijupiter/NoCsBack/dtai/pieterr/Projects/soccerdata/soccerdata/_common.py in _is_complete(self, league, season) 260 flip = {v: k for k, v in self._all_leagues().items()} 261 if league in flip: --> 262 league_dict = LEAGUE_DICT[flip[league]] 263 else: 264 raise ValueError(f"Invalid league '{league}'") KeyError: 'Big 5 European Leagues Combined' ```
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#43
No description provided.