New football-to-sqlite build tool - load / read football.txt match datafiles (e.g. English Premier League, German Bundesliga, Spanish La Liga, etc.) into a sqlite database

37 views
Skip to first unread message

Gerald Bauer

unread,
Oct 17, 2020, 9:21:34 AM10/17/20
to open...@googlegroups.com
Hello,

inspired by the datasette
{db,dbf,markdown,geojson,shapefile}-to-sqlite series [1] I have put
together the missing football-to-sqlite [2] tool that - surprise,
surprise - lets you load / read football.txt match datafiles (e.g.
English Premier League, German Bundesliga, Spanish La Liga 2020/21,
etc.) into a sqlite database.

Usage:

Run this tool against match files in the Football.TXT format like so:

```
$ football-to-sqlite england.db 2020-21\1-premierleague.txt
```

or pass in more than one match file:

```
$ football-to-sqlite england.db 2020-21\1-premierleague.txt \
2020-21\2-championship.txt \
2020-21\3-league1.txt \
2020-21\4-league2.txt \
2020-21\5-nationalleague.txt
```


Note: If the single-file SQLite database (and its tables, views &
indices) do not (yet) exist, they get auto-created on the first run.

Note: You can use `football2sqlite` as an alias / alternate name.


**Pipes & Standard Input (STDIN)**

You can use any command line tool to download match files and pipe
(via stdin) into this tool like so:

```
$ curl https://raw.githubusercontent.com/openfootball/world-cup/master/2018--russia/cup.txt
| football-to-sqlite worldcup.db
```

That's it for now. Enjoy the beautiful game with ruby. Cheers. Prost.


[1] https://docs.datasette.io/en/stable/ecosystem.html
[2] https://github.com/sportdb/football.db/tree/master/football-to-sqlite

NIKHIL B N

unread,
Oct 21, 2020, 3:00:51 AM10/21/20
to opensport
Hi Gerald,

Great work! I am first and foremost a Barcelona fan !
I  have created a react app as a personal project to display football stats from top 5 leagues, UCL and other cup competitions. I was looking for some free way to get data. Those api endpoints are very slow.

Today I found out your amazing work on openfootball.

Now I can run my own server to serve my frontend ( That would be my back-end project as well ! )

I would really appreciate if you could tell me how to download football-to-sqlite command line tool.

Thanks and regards,
Nikhil BN

Gerald Bauer

unread,
Oct 21, 2020, 3:10:10 AM10/21/20
to open...@googlegroups.com
Hello,
Thanks for your kind words. Greetings from Austria. Congrats,
another win for Barcelona in the Champions League yesterday (Tuesday).

> I would really appreciate if you could tell me how to download football-to-sqlite command line tool.

The football-to-sqlite command line tool is packaged as a ruby gem
(package). Installation in two steps:
Step 1: check if you have ruby installed - if not install ruby
Step 2: install the football-to-sqlite ruby package (gem)

Depending on your computer operating system you may have ruby
already installed - on Apple OS X ruby is already installed (as far as
I can remember - I personally use Windows / Linux).

On Linux you can use the package manager to install ruby if not
already installed
and on Windows you can use the Ruby Windows Installer, see
https://rubyinstaller.org

Also of course best to google ruby and your os / setup for more
info (or ask a friend).

Once you have ruby installed you will get a command line tool
called gem - try:

$ gem help

Use it to install the ruby package (gem) e.g.:

$ gem install football-to-sqlite

And than try

$ gem list

That shows all installed ruby packages / gems. And than of course try:

$ football-to-sqlite

Let us know how it goes. Good luck. Cheers. Prost.
Reply all
Reply to author
Forward
0 new messages