Hello,
I've put together the sportdb-reader gem / library [1] that
lets you read in (import) text datafiles into any SQL database (using
the sport.db schema / tables) using `SportDb.read`.
Try it with the English Premier League e.g. 2019-20/1-premierleague.txt [2]
or the Deutsche Bundesliga e.g. 2019-20/1-bundesliga.txt [3], for example.
From the readme:
**Step 1**
Setup the (SQL) database. Let's use and build a single-file SQLite
database (from scratch), as an example:
require 'sportdb/readers'
SportDb.connect( adapter: 'sqlite3',
database: './england.db' )
SportDb.create_all ## build database schema (tables, indexes, etc.)
**Step 2**
Let's read in some leagues, seasons, clubs, and match schedules and results.
Let's use the public domain football.db datasets for England (see
github.com/openfootball/england), as an example:
## turn on logging to console
ActiveRecord::Base.logger = Logger.new( STDOUT )
## assumes football.db datasets for England in ./england directory
## see github.com/openfootball/england
SportDb::ConfReaderV2.read( './england/2015-16/.conf.txt' )
SportDb::MatchReaderV2.read( './england/2015-16/1-premierleague-i.txt' )
SportDb::MatchReaderV2.read( './england/2015-16/1-premierleague-ii.txt' )
## let's try another season
SportDb::ConfReaderV2.read( './england/2019-20/.conf.txt' )
SportDb::MatchReaderV2.read( './england/2019-20/1-premierleague.txt' )
All leagues, seasons, clubs, match days and rounds, match fixtures and results,
and more are now in your (SQL) database of choice.
Or as an alternative use the `read` convenience all-in-one shortcut helper:
## assumes football.db datasets for England in ./england directory
## see github.com/openfootball/england
SportDb.read( './england/2015-16/.conf.txt' )
SportDb.read( './england/2015-16/1-premierleague-i.txt' )
SportDb.read( './england/2015-16/1-premierleague-ii.txt' )
## let's try another season
SportDb.read( './england/2019-20/.conf.txt' )
SportDb.read( './england/2019-20/1-premierleague.txt' )
Or as an alternative pass in the "package" directory and let `read`
figure out what datafiles to read:
## assumes football.db datasets for England in ./england directory
## see github.com/openfootball/england
SportDb.read( './england' )
Cheers. Prost.
[1] https://github.com/sportdb/sport.db/tree/master/sportdb-readers
[2] https://github.com/openfootball/england/blob/master/2019-20/1-premierleague.txt
[3] https://github.com/openfootball/deutschland/blob/master/2019-20/1-bundesliga.txt