Skip to content

Support single-file leagues in MatchHistory - #970

Open
shawnhdx0710 wants to merge 1 commit into
probberechts:masterfrom
shawnhdx0710:fix-matchhistory-single-file-leagues
Open

Support single-file leagues in MatchHistory#970
shawnhdx0710 wants to merge 1 commit into
probberechts:masterfrom
shawnhdx0710:fix-matchhistory-single-file-leagues

Conversation

@shawnhdx0710

@shawnhdx0710 shawnhdx0710 commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Football-data.co.uk publishes some leagues in a single file. The file holds the full match history for all seasons. The Swiss Super League is an example. These files live at /new/{league}.csv. They use a different subset of column names than the per-season files.

MatchHistory currently reads only the per-season files at /mmz4281/{season}/{league}.csv. For a single-file league, this URL does not exist. The request returns a 404. This change fixes issue #589.

What changed

  • The change adds a single_file flag to the league config.
  • For a single-file league, read_games downloads /new/{league}.csv once. It does not loop over the seasons.
  • It maps the single-file column names to the per-season column names. It fills the missing columns with NaN.
  • It filters the rows to the requested seasons.

How to use

Add a custom league to league_dict.json with the single_file flag:

{
  "SUI-Super League": {
    "MatchHistory": "SWZ",
    "single_file": true,
    "season_start": "Jul",
    "season_end": "May"
  }
}

Tests

Added test_read_games_single_file. It uses a synthetic fixture file. It does not hit the network.

Documentation

Updated docs/datasources/MatchHistory.ipynb.


Fixes #589

@shawnhdx0710

Copy link
Copy Markdown
Author

@probberechts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Match History] Different League URL for custom leagues

1 participant