probberechts / soccerdata

⛏⚽ Scrape soccer data from Club Elo, ESPN, FBref, FiveThirtyEight, Football-Data.co.uk, FotMob, Sofascore, SoFIFA, Understat and WhoScored.
https://soccerdata.readthedocs.io/en/latest/
Other
511 stars 87 forks source link

Cannot retrieve data from Custom League #601

Closed pranavm28 closed 1 month ago

pranavm28 commented 1 month ago

ValueError: Invalid league 'ARG-Liga Profesional'. Valid leagues are: ['ENG-Premier League', 'ESP-La Liga', 'FRA-Ligue 1', 'GER-Bundesliga', "INT-Women's World Cup", 'INT-World Cup', 'ITA-Serie A']

This is the error that I am getting. It's the same even if I try to scrape for the Brazilian league or the Portuguese league.

Here is my league_dict: | LEAGUE_DICT = { "ENG-Premier League": { "ClubElo": "ENG_1", "MatchHistory": "E0", "FiveThirtyEight": "premier-league", "FBref": "Premier League", "ESPN": "eng.1", "SoFIFA": "[England] Premier League", "WhoScored": "England - Premier League", "season_start": "Aug", "season_end": "May", }, "ESP-La Liga": { "ClubElo": "ESP_1", "MatchHistory": "SP1", "FiveThirtyEight": "la-liga", "FBref": "La Liga", "ESPN": "esp.1", "SoFIFA": "[Spain] La Liga", "WhoScored": "Spain - LaLiga", "season_start": "Aug", "season_end": "May", }, "ITA-Serie A": { "ClubElo": "ITA_1", "MatchHistory": "I1", "FiveThirtyEight": "serie-a", "FBref": "Serie A", "ESPN": "ita.1", "SoFIFA": "[Italy] Serie A", "WhoScored": "Italy - Serie A", "season_start": "Aug", "season_end": "May", }, "GER-Bundesliga": { "ClubElo": "GER_1", "MatchHistory": "D1", "FiveThirtyEight": "bundesliga", "FBref": "Fußball-Bundesliga", "ESPN": "ger.1", "SoFIFA": "[Germany] Bundesliga", "WhoScored": "Germany - Bundesliga", "season_start": "Aug", "season_end": "May", }, "FRA-Ligue 1": { "ClubElo": "FRA_1", "MatchHistory": "F1", "FiveThirtyEight": "ligue-1", "FBref": "Ligue 1", "ESPN": "fra.1", "SoFIFA": "[France] Ligue 1", "WhoScored": "France - Ligue 1", "season_start": "Aug", "season_end": "May", }, "INT-World Cup": { "FBref": "FIFA World Cup", "WhoScored": "International - FIFA World Cup", }, "ARG-Liga Profesional": { "WhoScored":"Argentina - Liga Profesional" }, "BRA-Brasileirao": { "WhoScored":"Brazil - Brasileirão", "season_start": "Apr", "season_end": "Dec", }, "POR-Liga Portugal": { "WhoScored":"Portugal - Liga Portugal", "season_start": "Aug", "season_end": "May", }

}

Seems like any new league that I am adding to the dictionary isn't being read. Or maybe I am making a huge mistake somewhere. Please help me in resolving this and thanks in advance!

probberechts commented 1 month ago
  1. Make sure to reload the soccerdata module after you modify the league_dict.json file. This file is parsed during the module's import.
  2. Check whether your league_dict.json file is at the correct location. If so, you should see this appear in the log messages.
$python
>>> import soccerdata as sd
[11/25/22 11:49:12] INFO     Custom team name replacements loaded from <path>/teamname_replacements.json.                                                                                                _config.py:83
                    INFO     Custom league dict loaded from <path>/league_dict.json.                                                                                                                    _config.py:153
  1. Check whether it is added to available leagues by running the command below.
>>> sd.WhoScored.available_leagues()
[ 'ENG-Premier League', 'ESP-La Liga', 'FRA-Ligue 1', 'GER-Bundesliga', 'INT-World Cup', 'ITA-Serie A']

If that doesn't work, you probably made a mistake in the syntax of your league_dict.json file

pranavm28 commented 1 month ago

Fixed! Thanks a lot, Rob!