Skip to content

football.db league quick starter sample - start your own leagues & cups

License

Notifications You must be signed in to change notification settings

openfootball/league-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

football.db League Quick Starter Sample - Mauritius Premier League

Yes, you can - create your own plain text datasets in the Football.TXT format for your own league(s) from scratch and read it all into your SQL database with a single command e.g.:

$ fbtxt2sqlite  mauritius.db  .

or convert to .JSON (with fbtxt2json) or .CSV (with fbtxt2csv).

Let's get started. Follow along these steps:

  • Step 1: Add all match fixtures and results in the Football.TXT format
  • Let's build. That's it. Done.

Using a file structure like:

mauritius/
└── 2014-15/                # 2014-15 season folder
    ├── 1-league-i.txt      #   match fixtures / results - matchdays  1-18
    └── 1-league-ii.txt     #                            - matchdays 19-36

Step 1: Add all match fixtures and results

Example - 2014-15/1-league-i.txt:

= Mauritius Premier League 2014/15 =

▪ Matchday 1
Wed Nov/5
  Curepipe Starlight     v Petite Rivière Noire   1-3
  AS Quatre Bornes       v La Cure Sylvester      1-0
  Pamplemousses          v Rivière du Rempart     0-1
  AS Port-Louis 2000     v Entente Boulet Rouge   5-1
  Chamarel SC            v Cercle de Joachim      2-3

▪ Matchday 2
Sun Nov/9
  Curepipe Starlight     v AS Quatre Bornes       2-1
  Entente Boulet Rouge   v Chamarel SC            1-2
  Rivière du Rempart     v AS Port-Louis 2000     1-1
  La Cure Sylvester      v Pamplemousses          1-2
  Petite Rivière Noire   v Cercle de Joachim      2-0

▪ Matchday 3
Wed Nov/12
  Chamarel SC            v Rivière du Rempart     1-1
  AS Port-Louis 2000     v La Cure Sylvester      1-0
  Cercle de Joachim      v Entente Boulet Rouge   2-2
  Pamplemousses          v Curepipe Starlight     0-4
  AS Quatre Bornes       v Petite Rivière Noire   1-2

▪ Matchday 4
Sun Nov/16
  Petite Rivière Noire   v Entente Boulet Rouge   4-1
  Rivière du Rempart     v Cercle de Joachim      1-1
  La Cure Sylvester      v Chamarel SC            0-0
  Curepipe Starlight     v AS Port-Louis 2000     0-0
  AS Quatre Bornes       v Pamplemousses          1-0

...

Aside - From RSSSF to Football.TXT

Note - The Mauritius Premier League sample was converted from the RSSSF Mauritius 2014/15 page, see https://www.rsssf.org/tablesm/mauri2015.html.

Before (RSSSF):

Round 1 [Nov 5]
Curepipe Starlight           1-3 Petite Rivière Noire         
AS Quatre-Bornes             1-0 La Cure Sylvester            
Pamplemousses                0-1 Rivière du Rempart           
ASPL 2000                    5-1 Ent. Boulet Rouge-Riche Mare 
Chamarel                     2-3 Cercle de Joachim            

What's changed?
Use a round marker e.g. and always make sure round header (lines) and date header (lines) are "standalone" lines.

Note - Do NOT enclose dates in brackets []. In Football.TXT brackets, that is,[], are reserved / used for match stati or comments e.g. [abandoned in 24' due to bad weather].

After (Football.TXT):

▪ Round 1 
Nov 5
  Curepipe Starlight           1-3 Petite Rivière Noire         
  AS Quatre-Bornes             1-0 La Cure Sylvester            
  Pamplemousses                0-1 Rivière du Rempart           
  ASPL 2000                    5-1 Ent. Boulet Rouge-Riche Mare 
  Chamarel                     2-3 Cercle de Joachim            

or use the versus-style e.g.

▪ Round 1 
Nov 5
  Curepipe Starlight   v Petite Rivière Noire           1-3         
  AS Quatre-Bornes     v La Cure Sylvester              1-0            
  Pamplemousses        v Rivière du Rempart             0-1           
  ASPL 2000            v Ent. Boulet Rouge-Riche Mare   5-1 
  Chamarel             v Cercle de Joachim              2-3

Let's try Round 9.

Before (RSSSF):

Round 9
[Dec 21]
Chamarel                     0-1 Petite Rivière Noire         
Cercle de Joachim            abd ASPL 2000                    [abandoned in 24' due to bad weather]
Ent. Boulet Rouge-Riche Mare 1-1 Pamplemousses                
Rivière du Rempart           2-2 AS Quatre-Bornes             
La Cure Sylvester            0-0 Curepipe Starlight           
[Jan 6]
Cercle de Joachim            2-0 ASPL 2000                    [replay]

What's changed?
Again use a round marker e.g. for the round header and remove the brackets [] from the date headers. For the replay match replace the [replay] note with a round header e.g. Round 9, Replay and, yes, you can keep the match status note as is.

After (Football.TXT):

▪ Round 9
Dec 21
  Chamarel                     v Petite Rivière Noire  0-1         
  Cercle de Joachim            v ASPL 2000                 [abandoned in 24' due to bad weather]
  Ent. Boulet Rouge-Riche Mare v Pamplemousses         1-1                
  Rivière du Rempart           v AS Quatre-Bornes      2-2             
  La Cure Sylvester            v Curepipe Starlight    0-0        
▪ Round 9, Replay
Jan 6
  Cercle de Joachim            v ASPL 2000             2-0              

Let's try Round 11.

Before (RSSSF):

Round 11 
[Jan 4]
Cercle de Joachim            3-0 Petite Rivière Noire         
Chamarel                     2-2 Ent. Boulet Rouge-Riche Mare 
ASPL 2000                    awd Rivière du Rempart           [awarded 3-0; originally 2-0]
Pamplemousses                awd La Cure Sylvester            [awarded 3-0; originally 1-3,
[Jan 6]                                                        La Cure Sylvester fielded
AS Quatre-Bornes             0-1 Curepipe Starlight            ineligible players]

What's changed?
Again use a round marker e.g. for the round header and remove the brackets [] from the date headers. For the awarded matches - remove the awd tag and replace with the awarded score, that is, 3-0, and yes, you can keep the match status note (but make sure it's single line) and let's remove the now redundant 3-0 score.

After (Football.TXT):

▪ Round 11 
Jan 4
  Cercle de Joachim            v Petite Rivière Noire          3-0         
  Chamarel                     v Ent. Boulet Rouge-Riche Mare  2-2 
  ASPL 2000                    v Rivière du Rempart            3-0 [awarded; originally 2-0]
  Pamplemousses                v La Cure Sylvester             3-0 [awarded; originally 1-3, ...]
Jan 6                   
  AS Quatre-Bornes             v Curepipe Starlight            0-1            

Let's add / try the Promotion/Relegation Playoff.

Before (RSSSF):

Promotion/Relegation Playoff

Round 1 [Jul 19]
Bolton City                  0-3 La Cure Sylvester            

Round 2 [Jul 22]
Savanne                      2-2 Bolton City                  

Round 3 [Jul 25]
La Cure Sylvester            2-0 Savanne                      

What's changed?
Tip - if you add a stage to a match schedule, add the stage e.g. Promotion/Relegation Playoff or a shortcut e.g. Relegation upfront to all rounds, thus, Round 1 becomes Relegation, Round 1 and Round 2 becomes Relegation Round 2 and so on.

After (Football.TXT):

# Promotion/Relegation Playoff

▪ Relegation, Round 1 
Jul 19
  Bolton City               v La Cure Sylvester   0-3            

▪ Relegation, Round 2 
Jul 22
  Savanne                   v Bolton City         2-2                  

▪ Relegation, Round 3 
Jul 25
  La Cure Sylvester         v Savanne             2-0                     

For more, see the Football.TXT format, level 1 & 2 specs »

Let's build. That's it. Done.


Tip - Step 0 - fbtxt2sqlite Installation via Gems (Package Manager)

To install the fbtxt2sqlite command-line tool use the gems command-line tool, that is, ruby's package manager. Type:

 $ gem install fbtxt2sqlite

To check-up on the installation try:

 $ fbtxt2sqlite -h        # or
 $ fbtxt2sqlite --help

resulting in:

Usage: fbtxt2sqlite [options] DBPATH PATH
        --verbose, --debug           turn on verbose / debug output (default: false)
        --seasons SEASONS            turn on processing only seasons (default: false)

Now try in your working folder:

$ fbtxt2sqlite mauritius.db .

This will run the build machinery and

  • setup a new single-file SQLite database e.g. ./mauritius.db from scratch (zero)
  • read in all plain text datasets in the Football.TXT format in the working directory e.g. ./

That's it. Try:

$ sqlite3 mauritius.db

SQLite version 3.7.16
Enter ".help" for instructions
Enter SQL statements terminated with a ";"


sqlite> select * from leagues;

1|mu_premierleague|Premier League|...
2|mu_cup|Cup|...

sqlite> select * from teams;

 1|Curepipe Starlight|...
 2|Petite Rivière Noire|...
 3|AS Quatre Bornes|..
 4|La Cure Sylvester|...
 5|Pamplemousses|...
 6|Rivière du Rempart|...
 7|AS Port-Louis 2000|...
 8|Entente Boulet Rouge|...
 9|Chamarel SC|...
10|Cercle de Joachim|...
11|Pointe-aux-Sables Mates|...
12|Savanne SC|...

sqlite> select * from events;

1|mu_premierleague.2014/15|...
2|mu_cup.2015|...

sqlite> select * from matches;
...

And so on.

Tips & Tricks

More Formats

You can use the fbtxt2json command-line tool to convert any file in the Football.TXT format to JSON.

Let's try to convert the Mauritus Premier League 2014/15 in the Football.TXT format (see 2014-15/1-league-i.txt and 2014-15/1-league-ii.txt ) to JSON:

$ fbtxt2json 2014-15/1-league-i.txt 2014-15/1-league-ii.txt -o mu.1.json

Resulting in:

{
  "name": "Mauritius Premier League 2014/15",
  "matches": [
    {
      "round": "Matchday 1",
      "date": "2014-11-05",
      "team1": "Curepipe Starlight",
      "team2": "Petite Rivière Noire",
      "score": { "ft": [1,3] }
    },
    {
      "round": "Matchday 1",
      "date": "2014-11-05",
      "team1": "AS Quatre Bornes",
      "team2": "La Cure Sylvester",
      "score": { "ft": [1,0] }
    },
    // ...
  ]
}

or convert all datasets all-at-once by passing in the directory:

$ fbtxt2json .

resulting in:

mauritius/
└── 2014-15/            
    ├── 1-league-i.json
    └── 1-league-ii.json

For an all-in-one .CSV datafile use the fbtxt2csv command-line tool. Try:

$ fbtxt2csv ./ -o mauritius.csv

resulting in:

League,Date,Team 1,Team 2,FT,ET,P,Round,Status
Mauritius Premier League 2014/15,2014-11-05,Curepipe Starlight,Petite Rivière Noire,1-3,,,Matchday 1,
Mauritius Premier League 2014/15,2014-11-05,AS Quatre Bornes,La Cure Sylvester,1-0,,,Matchday 1,
Mauritius Premier League 2014/15,2014-11-05,Pamplemousses,Rivière du Rempart,0-1,,,Matchday 1,
Mauritius Premier League 2014/15,2014-11-05,AS Port-Louis 2000,Entente Boulet Rouge,5-1,,,Matchday 1,
Mauritius Premier League 2014/15,2014-11-05,Chamarel SC,Cercle de Joachim,2-3,,,Matchday 1,
Mauritius Premier League 2014/15,2014-11-09,Curepipe Starlight,AS Quatre Bornes,2-1,,,Matchday 2,
Mauritius Premier League 2014/15,2014-11-09,Entente Boulet Rouge,Chamarel SC,1-2,,,Matchday 2,
Mauritius Premier League 2014/15,2014-11-09,Rivière du Rempart,AS Port-Louis 2000,1-1,,,Matchday 2,
Mauritius Premier League 2014/15,2014-11-09,La Cure Sylvester,Pamplemousses,1-2,,,Matchday 2,
# ...

Debugging & Troubleshooting

You can use the fbtok command-line tool shipping with the sportdb machinery to check-up on the Football.TXT tokenizer / tokens.

Let's try the Mauritus Republic Cup 2024 (see 2024/republic-cup.txt):

$ fbtok 2024/republic-cup.txt

Resulting in:

line >Round 1<
[[:round, "Round 1"]]

line >[Apr 28]<
[[:date, "Apr 28", {:m=>4, :d=>28}]]

line >Cercle de Joachim            3-2  EBRRMR<
[[:team, "Cercle de Joachim"], [:score, "3-2", {:ft=>[3, 2]}], [:team, "EBRRMR"]]

line >Chebel Citizens              2-0  ASPL 2000<
[[:team, "Chebel Citizens"], [:score, "2-0", {:ft=>[2, 0]}], [:team, "ASPL 2000"]]

line >Quarterfinals<
[[:round, "Quarterfinals"]]

line >[May 8]<
[[:date, "May 8", {:m=>5, :d=>8}]]

line >Savanne                      2-1  Chebel Citizens<
[[:team, "Savanne"], [:score, "2-1", {:ft=>[2, 1]}], [:team, "Chebel Citizens"]]

...

line >Final<
[[:round, "Final"]]

line >[Jul 27]<
[[:date, "Jul 27", {:m=>7, :d=>27}]]

line >Cercle de Joachim            1-0   AS Rivière du Rempart<
[[:team, "Cercle de Joachim"], [:score, "1-0", {:ft=>[1, 0]}], [:team, "AS Rivière du Rempart"]]

OK   no parse errors found

Questions? Comments?

Yes, you can. More than welcome. See Help & Support »

About

football.db league quick starter sample - start your own leagues & cups

Resources

License

Stars

Watchers

Forks