ML-KULeuven / socceraction

Convert soccer event stream data to SPADL and value player actions using VAEP or xT
MIT License
579 stars 133 forks source link

Path issue on Windows #457

Closed WUSER-why closed 1 year ago

WUSER-why commented 1 year ago

Hi, I'm trying to use the loader for whoscored.com on Windows, but receive a path issue:

ValueError: The filepath C:\Users\User\soccerdata\data\WhoScored\events/ENG-Premier League_2021\1485184.json does not match the format events/{competitionid}{season_id}/{game_id}.json.

2 issues: 1) specifically for loader.games, it inserts a "/" before the league id. This does not happen for, e.g., loader.events 2) in all cases, it raises the ValueError "does not match the format events/{competitionid}{season_id}/{game_id}.json

Any thoughts for how I can fix this?

Thanks

probberechts commented 1 year ago

Sorry for the late reply.

One thing to pay attention to is that you should use backward slashes in your root and feeds parameters. The implementation uses the os.path module to join the root and feed, so it should automatically insert the correct one. Hence, I do not understand where the "/" comes from between "WhoScored" and "events".

I think you made a mistake in specifying either the root path or the feeds. I guess it should be something like this:

from socceraction.data.opta import OptaLoader

loader = OptaLoader(
    root="C:\Users\User\soccerdata\data\WhoScored\events",
    parser="whoscored",
    feeds = {
        'whoscored': "{competition_id}_{season_id}\{game_id}.json",
    }
)
loaders.games(competition_id="ENG-Premier League", season_id="2021")