Hello,
I've updated the sportdb-importers [1] gem
that lets you read (import) league & match datasets
in comma-separated values (CSV) format into any SQL database.
What's news?
A new CSV flavor / schema lets you read in any or many leagues or
seasons per datafile,
for example, week by week or year by year.
From the footballcsv updates dataset:
Date, League, Team 1, FT, Team 2
Wed Jun 10 2020, DE 3, SpVgg Unterhaching, 1-3, Eintracht Braunschweig
Thu Jun 11 2020, AT 2, FC Blau-Weiß Linz, 1-2, Austria Klagenfurt
Thu Jun 11 2020, ES 1, Sevilla FC, 2-0, Real Betis
...
Let's build an update.db from scratch:
require 'sportdb/importers'
SportDb.connect( adapter: 'sqlite3',
database: './updates.db' )
SportDb.create_all ## build database schema (tables, indexes, etc.)
## note: requires a local copy of the football.csv updates datasets
## see https://github.com/footballcsv/updates
SportDb.read_csv( './updates' )
# -or- use a zip archive
SportDb.read_csv( './updates.zip' )
That's it. Enjoy the beautiful game with ruby.
Happy data wrangling. Cheers. Prost.
PS:
Q: What codes or names for league & cups can I use?
The importers ship with hundreds of zero-config preconfigured
code and names for leagues & cups.
See the /leagues [2] datasets for all builtin
national and international football club leagues & cups from around the world.
Or to query in ruby try:
require `sportdb/config`
LEAGUES = SportDb::Import.catalog.leagues
LEAGUES.find( 'ENG 1' ) #=> Premier League › England
LEAGUES.find( 'EPL' ) #=> Premier League › England
LEAGUES.find( 'ENG 2' ) #=> Championship › England
LEAGUES.find( 'ENG CS' ) #=> Championship › England
LEAGUES.find( 'ES' ) #=> Primera División › Spain
LEAUGES.find( 'ESP 1') #=> Primera División › Spain
...
[1] https://github.com/sportdb/sport.db/tree/master/sportdb-importers
[2] https://github.com/openfootball/leagues