sportdb-importers - tools 'n' scripts for importing sports (football) data in alternate (text) formats incl. comma-separated values (csv) format

Usage

Step 1

Setup the (SQL) database. Let's use and build a single-file SQLite database (from scratch), as an example:

require 'sportdb/importers'

SportDb.connect( adapter:  'sqlite3',
                 database: './england.db' )
SportDb.create_all       ## build database schema (tables, indexes, etc.)

Step 2

Let's use the public domain football.csv datasets for England (see footballcsv/england), as an example:

Round, Date,              Team 1,               FT,  HT,  Team 2
1,     (Fri)  9 Aug 2019, Liverpool FC,         4-1, 4-0, Norwich City FC
1,     (Sat) 10 Aug 2019, West Ham United FC,   0-5, 0-1, Manchester City FC
1,     (Sat) 10 Aug 2019, AFC Bournemouth,      1-1, 0-0, Sheffield United FC
1,     (Sat) 10 Aug 2019, Burnley FC,           3-0, 0-0, Southampton FC
1,     (Sat) 10 Aug 2019, Crystal Palace FC,    0-0, 0-0, Everton FC
1,     (Sat) 10 Aug 2019, Watford FC,           0-3, 0-1, Brighton & Hove Albion FC
1,     (Sat) 10 Aug 2019, Tottenham Hotspur FC, 3-1, 0-1, Aston Villa FC
1,     (Sun) 11 Aug 2019, Leicester City FC,    0-0, 0-0, Wolverhampton Wanderers FC
1,     (Sun) 11 Aug 2019, Newcastle United FC,  0-1, 0-0, Arsenal FC
1,     (Sun) 11 Aug 2019, Manchester United FC, 4-0, 1-0, Chelsea FC
...

(Source: england/2019-20/eng.1.csv)

and let's try:

## assumes football.csv datasets for England in ./england directory
##   see github.com/footballcsv/england
SportDb.read_csv( './england/2019-20/eng.1.csv' )

## let's try another season
SportDb.read_csv( './england/2018-19/eng.1.csv' )
SportDb.read_csv( './england/2018-19/eng.2.csv' )

All leagues, seasons, clubs, match days and rounds, match fixtures and results, and more are now in your (SQL) database of choice.

Bonus: Let's import all datafiles for all seasons (from 1888-89 to today) for England, use:

## note: requires a local copy of the football.csv england datasets
##          see https://github.com/footballcsv/england
SportDb.read_csv( './england' )
# -or-    use a zip archive
SportDb.read_csv( './england.zip' )

That's it.

License

The sportdb-importers scripts are dedicated to the public domain. Use it as you please with no restrictions whatsoever.

Questions? Comments?

Send them along to the Open Sports & Friends Forum/Mailing List. Thanks!