mirror of
https://github.com/probberechts/soccerdata.git
synced 2026-04-25 10:05:53 +03:00
[GH-ISSUE #104] In-depth tutorial on how to add new leagues? #23
Labels
No labels
ESPN
FBref
FotMob
MatchHistory
SoFIFA
Sofascore
WhoScored
WhoScored
bug
build
common
dependencies
discussion
documentation
duplicate
enhancement
good first issue
invalid
performance
pull-request
question
question
removal
understat
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/soccerdata#23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cj0121 on GitHub (Nov 25, 2022).
Original GitHub issue: https://github.com/probberechts/soccerdata/issues/104
Hi,
This is an amazing package! I think the docs are mostly very clear. However, is it possible to have a more in-depth tutorial on how to add new leagues to FBRef? I'm trying to add the English Championship, which is available on FB Ref, but wasn't able to. I added a
league_dict.jsonfile (with the correct config I assume) to the"SOCCERDATA_DIR/config/"file path, but it seems like the code is not picking up on it when I callfbref = sd.FBref(leagues="EFL Championship", seasons=2019). It gave me a ValueError noting "Invalid League". Thank you so much!@philbywalsh commented on GitHub (Nov 25, 2022):
Hi @cj0121 - try pasting in here the entry which you made in the league_dict.json file. Perhaps there's a syntax error?
@probberechts commented on GitHub (Nov 25, 2022):
I think it is indeed a good idea to extend the documentation for adding additional leagues. Multiple people seem to be struggling with that.
Now, to resolve your problem, you should:
league_dict.jsonfile. This file is parsed during the module's import.league_dict.jsonfile is at the correct location. If so, you should see this appear in the log messages.If that doesn't work, you probably made a mistake in the syntax of your
league_dict.jsonfile. Paste it here and we'll try to help you.@cj0121 commented on GitHub (Nov 26, 2022):
Thanks for getting back! Bellow is my
league_dict.jsonfile:As you can see I added
EFL ChampionshipandNED-Eredivisie. TheNED-Eredivisieis a straight copy from the docs. Additional question: for each additional league, is it required to include all five data sources as properties. If yes, the values of those need to be matched by the whatever ID used on the original sites, correct?Currently I have the json file here on my mac:
User/soccerdata/config/league_dict.json. I think the file location might be the problem. I wasn't able to locateSOCCERDATA_DIRsuggested in the docs.Much appreciated!
@probberechts commented on GitHub (Nov 26, 2022):
No, you do not have to include all five data sources, nor the "season_start" and "season_end" fields.
There is one error in your json file: you should remove the comma at the end of the second to last line to have a valid json file.
You can see where it looks for the json file in the log messages that are printed when importing the library.
@cj0121 commented on GitHub (Nov 27, 2022):
I got it to work finally! Thanks so much for the help! Turned out to be much easier than I thought. Just needed to make sure the
league_dict.jsonis of correct syntax and at the right place.@andrzej-konczyk commented on GitHub (Apr 19, 2023):
Hi, I have simillar case but only now with Eredivisie. I've created league_dict.json which includes :
{ "NED-Eredivisie": { "ClubElo": "NED_1", "MatchHistory": "N1", "SoFIFA": "Holland Eredivisie (1)", "FBref": "Dutch Eredivisie", "ESPN": "ned.1", "FiveThirtyEight": "eredivisie", "WhoScored": "Netherlands - Eredivisie", "season_start": "Aug", "season_end": "May" } }and after run _config.py I see comment that league is added, but when I runsd.FBref.available_leagues()then I do not have that new league there - I do not knoiw why@probberechts commented on GitHub (Apr 20, 2023):
@andrzej-konczyk Your json seems correct. I do not really get what you mean by "after run _config.py I see comment that league is added" though. The file
_config.pyis not an executable.One hint I can think of: make sure to reload all imported soccerdata modules after modifying the
league_dict.jsonfile. The most straightforward way to do this is to restart your notebook or python interpreter.@andrzej-konczyk commented on GitHub (Apr 21, 2023):
Yeah , restart helped. Thanks!
@Lushin415 commented on GitHub (May 15, 2023):
And where can I see the correct names for the leagues? Let's say where you could see the name of the Dutch league on the ESPN website?
"ESPN": "ned.1","@lorenzodb1 commented on GitHub (Jun 29, 2023):
It appears that the docs are wrong regarding how to add additional leagues for FBref. For instance, it suggests adding to
league_dict.jsonwhen one should actually add
for it to actually work. Not sure if the name used in FBref changed after the example was written, but I just thought of pointing it out as it's quite confusing.
@WillT23 commented on GitHub (Jul 20, 2023):
Hi, firstly thanks for creating this, I've found it so useful.
I'm having some trouble trying to customise the code to include the Women's World Cup. I've followed the same process of adding other leagues which I've been successful with, but i'm getting the following error. I've also pasted the relevant part of my league_dict json.
KeyError: "None of [Index(['WWC-WWC'], dtype='object', name='league')] are in the [index]"
"WWC-WWC": {
"WhoScored": "International - FIFA Women s World Cup",
"season_start": "Jul",
"season_end": "Sep"
}
Thanks,
Will
@probberechts commented on GitHub (Jul 20, 2023):
@WillT23 I believe it should be "International - FIFA Women's World Cup". You forgot the apostrophe.
@WillT23 commented on GitHub (Jul 20, 2023):
Thanks for the reply, although unfortunately I'm still having the same issue when the apostrophe is in the right place.
@probberechts commented on GitHub (Jul 20, 2023):
@WillT23 It seems to work fine. See #299. Make sure to reload the soccerdata module after you modify the
league_dict.jsonfile and disable caching after adding a new league.@WillT23 commented on GitHub (Jul 20, 2023):
Perfect, works now. Thanks so much for your help!