footballdata-12xpert 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +1 -0
- data/README.md +199 -36
- data/lib/footballdata-12xpert.rb +7 -118
- data/lib/footballdata-12xpert/config.rb +241 -219
- data/lib/footballdata-12xpert/convert.rb +3 -7
- data/lib/footballdata-12xpert/import.rb +21 -0
- data/lib/footballdata-12xpert/version.rb +2 -2
- data/test/test_import.rb +4 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96ce5cd82665871ff21e654619be6cd0c43c8b68
|
4
|
+
data.tar.gz: 6153b37d95190031bff57618554ddd3c973ac046
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cae4688ec1b1a30115ba30d701ba1716abfeacd32c8421dae2db475a2dc30f484f0dce96348c610da3c1e98a37f8805ea2be2f6ba4e4944b13773942b574821d
|
7
|
+
data.tar.gz: b11525344e6255c87b41758f6eb5d47f350a17545b2bac950684ce4031eb9fd2aef177f9e1952f0a54e24fd91747f2b830b6d622d9f629455a78f1553cfd4ccc
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -57,6 +57,11 @@ and get at least updated twice weekly
|
|
57
57
|
|
58
58
|
## Usage
|
59
59
|
|
60
|
+
[Download](#download) • [Convert](#convert) • [Import](#import)
|
61
|
+
|
62
|
+
|
63
|
+
### Download
|
64
|
+
|
60
65
|
Let's download all datasets (about 570+) for offline usage into the
|
61
66
|
default web cache directory (that is, `~/.cache/www.football-data.co.uk`):
|
62
67
|
|
@@ -94,7 +99,7 @@ Stand back ten feet. Resulting in:
|
|
94
99
|
│ SWZ.csv
|
95
100
|
│ USA.csv
|
96
101
|
│
|
97
|
-
├───9394
|
102
|
+
├───9394 # 1993/94 season by season main top leagues
|
98
103
|
│ D1.csv
|
99
104
|
│ D2.csv
|
100
105
|
│ E0.csv
|
@@ -106,7 +111,7 @@ Stand back ten feet. Resulting in:
|
|
106
111
|
│ N1.csv
|
107
112
|
│ SP1.csv
|
108
113
|
│
|
109
|
-
├───9495
|
114
|
+
├───9495 # 1994/95 season by season main top leagues
|
110
115
|
│ D1.csv
|
111
116
|
│ D2.csv
|
112
117
|
│ E0.csv
|
@@ -123,7 +128,7 @@ Stand back ten feet. Resulting in:
|
|
123
128
|
│ SP1.csv
|
124
129
|
│ T1.csv
|
125
130
|
...
|
126
|
-
├───
|
131
|
+
├───1920 # 2019/20 season by season main top leagues
|
127
132
|
│ B1.csv
|
128
133
|
│ D1.csv
|
129
134
|
│ D2.csv
|
@@ -147,7 +152,7 @@ Stand back ten feet. Resulting in:
|
|
147
152
|
│ SP2.csv
|
148
153
|
│ T1.csv
|
149
154
|
│
|
150
|
-
└───
|
155
|
+
└───2021 # 2020/21 season by season main top leagues
|
151
156
|
B1.csv
|
152
157
|
D1.csv
|
153
158
|
D2.csv
|
@@ -171,10 +176,10 @@ Stand back ten feet. Resulting in:
|
|
171
176
|
|
172
177
|
The football datasets come in two flavors / formats.
|
173
178
|
The main leagues use season-by-season datafiles.
|
174
|
-
For example, `E0.csv`, `E1.csv`, `E2.csv`, `E3.csv` & `E4.csv` in the `
|
179
|
+
For example, `E0.csv`, `E1.csv`, `E2.csv`, `E3.csv` & `E4.csv` in the `2021`
|
175
180
|
season directory hold the matches for the English Premiership & Divs 1, 2, 3 & Conference;
|
176
181
|
`D1.csv` & `D2.csv` for the Bundesligas 1 & 2 and so on
|
177
|
-
for the
|
182
|
+
for the 2020/21 season.
|
178
183
|
|
179
184
|
The extra leagues use an all-seasons-in-one datafile.
|
180
185
|
For example, `ARG.csv`
|
@@ -192,7 +197,7 @@ You can download datasets for selected countries only. Pass in
|
|
192
197
|
the country keys. Let's download only England (`eng`)'s leagues:
|
193
198
|
|
194
199
|
``` ruby
|
195
|
-
|
200
|
+
Footballdata12xpert.download( 'eng' )
|
196
201
|
```
|
197
202
|
|
198
203
|
Or let's download only the top five leagues, that is,
|
@@ -200,12 +205,158 @@ England (`eng`), Spain (`es`), Germany (`de`), France (`fr`)
|
|
200
205
|
and Italy (`it`):
|
201
206
|
|
202
207
|
``` ruby
|
203
|
-
|
208
|
+
Footballdata12xpert.download( 'eng', 'es', 'de', 'fr', 'it' )
|
209
|
+
```
|
210
|
+
|
211
|
+
### Convert
|
212
|
+
|
213
|
+
Now what? Let's convert all football datasets from the web cache
|
214
|
+
to the one-line, one-match & one-file, one-season "standard" [Football.CSV format](https://github.com/footballcsv).
|
215
|
+
Example:
|
216
|
+
|
217
|
+
|
218
|
+
``` ruby
|
219
|
+
require 'footballdata/12xpert'
|
220
|
+
|
221
|
+
Footballdata12xpert.convert
|
222
|
+
```
|
223
|
+
|
224
|
+
Stand back ten feet. Resulting in:
|
225
|
+
|
226
|
+
```
|
227
|
+
./o
|
228
|
+
├───1993-94
|
229
|
+
│ de.1.csv
|
230
|
+
│ de.2.csv
|
231
|
+
│ eng.1.csv
|
232
|
+
│ eng.2.csv
|
233
|
+
│ eng.3.csv
|
234
|
+
│ eng.4.csv
|
235
|
+
│ es.1.csv
|
236
|
+
│ fr.1.csv
|
237
|
+
│ it.1.csv
|
238
|
+
│ nl.1.csv
|
239
|
+
│
|
240
|
+
├───1994-95
|
241
|
+
│ de.1.csv
|
242
|
+
│ de.2.csv
|
243
|
+
│ eng.1.csv
|
244
|
+
│ eng.2.csv
|
245
|
+
│ eng.3.csv
|
246
|
+
│ eng.4.csv
|
247
|
+
│ es.1.csv
|
248
|
+
│ fr.1.csv
|
249
|
+
│ gr.1.csv
|
250
|
+
│ it.1.csv
|
251
|
+
│ nl.1.csv
|
252
|
+
│ pt.1.csv
|
253
|
+
│ sco.1.csv
|
254
|
+
│ sco.2.csv
|
255
|
+
│ tr.1.csv
|
256
|
+
...
|
257
|
+
├───2020
|
258
|
+
│ ar.1.csv
|
259
|
+
│ br.1.csv
|
260
|
+
│ cn.1.csv
|
261
|
+
│ fi.1.csv
|
262
|
+
│ ie.1.csv
|
263
|
+
│ jp.1.csv
|
264
|
+
│ no.1.csv
|
265
|
+
│ se.1.csv
|
266
|
+
│ us.1.csv
|
267
|
+
│
|
268
|
+
└───2020-21
|
269
|
+
at.1.csv
|
270
|
+
be.1.csv
|
271
|
+
ch.1.csv
|
272
|
+
de.1.csv
|
273
|
+
de.2.csv
|
274
|
+
dk.1.csv
|
275
|
+
eng.1.csv
|
276
|
+
eng.2.csv
|
277
|
+
eng.3.csv
|
278
|
+
eng.4.csv
|
279
|
+
eng.5.csv
|
280
|
+
es.1.csv
|
281
|
+
es.2.csv
|
282
|
+
```
|
283
|
+
|
284
|
+
Note: By default all datasets get written into the `./o`
|
285
|
+
directory. Use `Footballdata12xpert.config.convert.out_dir`
|
286
|
+
to change the output directory.
|
287
|
+
|
288
|
+
The English Premier League (`eng.1`) results in `./o/2020-21/eng.1.csv`:
|
289
|
+
|
290
|
+
```
|
291
|
+
Date,Team 1,FT,HT,Team 2
|
292
|
+
Sat Sep 12 2020,Fulham,0-3,0-1,Arsenal
|
293
|
+
Sat Sep 12 2020,Crystal Palace,1-0,1-0,Southampton
|
294
|
+
Sat Sep 12 2020,Liverpool,4-3,3-2,Leeds
|
295
|
+
Sat Sep 12 2020,West Ham,0-2,0-0,Newcastle
|
296
|
+
Sun Sep 13 2020,West Brom,0-3,0-0,Leicester
|
297
|
+
Sun Sep 13 2020,Tottenham,0-1,0-0,Everton
|
298
|
+
Mon Sep 14 2020,Brighton,1-3,0-1,Chelsea
|
299
|
+
Mon Sep 14 2020,Sheffield United,0-2,0-2,Wolves
|
300
|
+
Sat Sep 19 2020,Everton,5-2,2-1,West Brom
|
301
|
+
Sat Sep 19 2020,Leeds,4-3,2-1,Fulham
|
302
|
+
Sat Sep 19 2020,Man United,1-3,0-1,Crystal Palace
|
303
|
+
...
|
304
|
+
```
|
305
|
+
|
306
|
+
Or the Brasileirão (`br.1`) in `./o/2020/br.1.csv`:
|
307
|
+
|
308
|
+
```
|
309
|
+
Date,Team 1,FT,HT,Team 2
|
310
|
+
Sat Aug 8 2020,Fortaleza,0-2,?,Athletico-PR
|
311
|
+
Sat Aug 8 2020,Coritiba,0-1,?,Internacional
|
312
|
+
Sat Aug 8 2020,Sport Recife,3-2,?,Ceara
|
313
|
+
Sun Aug 9 2020,Flamengo RJ,0-1,?,Atletico-MG
|
314
|
+
Sun Aug 9 2020,Santos,1-1,?,Bragantino
|
315
|
+
Sun Aug 9 2020,Gremio,1-0,?,Fluminense
|
316
|
+
Wed Aug 12 2020,Athletico-PR,2-1,?,Goias
|
317
|
+
Wed Aug 12 2020,Atletico-MG,3-2,?,Corinthians
|
318
|
+
Wed Aug 12 2020,Bragantino,1-1,?,Botafogo RJ
|
319
|
+
Wed Aug 12 2020,Atletico GO,3-0,?,Flamengo RJ
|
320
|
+
Wed Aug 12 2020,Bahia,1-0,?,Coritiba
|
321
|
+
...
|
322
|
+
```
|
323
|
+
|
324
|
+
and so on.
|
325
|
+
|
326
|
+
|
327
|
+
Less is More?
|
328
|
+
|
329
|
+
You can convert datasets for selected countries only. Pass in
|
330
|
+
the country keys. Let's download only England (`eng`)'s leagues:
|
331
|
+
|
332
|
+
``` ruby
|
333
|
+
Footballdata12xpert.convert( 'eng' )
|
334
|
+
```
|
335
|
+
|
336
|
+
Or let's convert only the top five leagues, that is,
|
337
|
+
England (`eng`), Spain (`es`), Germany (`de`), France (`fr`)
|
338
|
+
and Italy (`it`):
|
339
|
+
|
340
|
+
``` ruby
|
341
|
+
Footballdata12xpert.convert( 'eng', 'es', 'de', 'fr', 'it' )
|
204
342
|
```
|
205
343
|
|
344
|
+
Or let's convert only the top five leagues starting from the 2019/20 season on:
|
345
|
+
|
346
|
+
``` ruby
|
347
|
+
Footballdata12xpert.convert( 'eng', 'es', 'de', 'fr', 'it', start: '2019/20' )
|
348
|
+
```
|
349
|
+
|
350
|
+
|
351
|
+
### Import
|
352
|
+
|
353
|
+
Now what? Let's import all (converted) football datasets
|
354
|
+
in the one-line, one-match & one-file, one-season "standard"
|
355
|
+
Football.CSV format into an SQL database.
|
206
356
|
|
207
|
-
|
208
|
-
|
357
|
+
Note: By default all datasets get read in from the `./o`
|
358
|
+
output directory. Use `Footballdata12xpert.config.convert.out_dir`
|
359
|
+
to change the output directory.
|
209
360
|
|
210
361
|
|
211
362
|
``` ruby
|
@@ -215,7 +366,7 @@ SportDb.connect( adapter: 'sqlite3',
|
|
215
366
|
SportDb.create_all ## build database schema / tables
|
216
367
|
|
217
368
|
|
218
|
-
|
369
|
+
Footballdata12xpert.import
|
219
370
|
```
|
220
371
|
|
221
372
|
Note: Depending on your computing processing power the import might take
|
@@ -227,18 +378,18 @@ Done. Let's try some database (SQL) queries (using the sport.db ActiveRecord mod
|
|
227
378
|
``` ruby
|
228
379
|
## ActiveRecord model (convenience) shortcuts
|
229
380
|
Team = SportDb::Model::Team
|
230
|
-
|
381
|
+
Match = SportDb::Model::Match
|
231
382
|
League = SportDb::Model::League
|
232
383
|
Event = SportDb::Model::Event
|
233
384
|
|
234
385
|
|
235
|
-
## Let's query for some stats - How many teams? How many
|
386
|
+
## Let's query for some stats - How many teams? How many matches? etc.
|
236
387
|
|
237
388
|
puts Team.count #=> 1143
|
238
389
|
# SELECT COUNT(*) FROM teams
|
239
390
|
|
240
|
-
puts
|
241
|
-
# SELECT COUNT(*) FROM
|
391
|
+
puts Match.count #=> 227_142
|
392
|
+
# SELECT COUNT(*) FROM matches
|
242
393
|
|
243
394
|
puts League.count #=> 38
|
244
395
|
# SELECT COUNT(*) FROM leagues
|
@@ -250,41 +401,41 @@ club names by country.
|
|
250
401
|
``` ruby
|
251
402
|
## Let's query for the Real Madrid football club from Spain
|
252
403
|
|
253
|
-
madrid = Team.find_by(
|
254
|
-
# SELECT * FROM teams WHERE
|
404
|
+
madrid = Team.find_by( name: 'Real Madrid' )
|
405
|
+
# SELECT * FROM teams WHERE name = 'Real Madrid' LIMIT 1
|
255
406
|
|
256
|
-
puts madrid.
|
257
|
-
# SELECT COUNT(*) FROM
|
258
|
-
|
259
|
-
# SELECT * FROM
|
407
|
+
puts madrid.matches.count #=> 1023
|
408
|
+
# SELECT COUNT(*) FROM matches WHERE (team1_id = 380 or team2_id = 380)
|
409
|
+
m = madrid.matches.first
|
410
|
+
# SELECT * FROM matches WHERE (team1_id = 380 or team2_id = 380) LIMIT 1
|
260
411
|
|
261
|
-
puts
|
262
|
-
puts
|
263
|
-
puts
|
412
|
+
puts m.team1.name #=> CA Osasuna
|
413
|
+
puts m.team2.name #=> Real Madrid
|
414
|
+
puts m.score_str #=> 1 - 4
|
264
415
|
|
265
416
|
|
266
417
|
## Or let's query for the Liverpool football club from England
|
267
418
|
|
268
|
-
liverpool = Team.find_by(
|
419
|
+
liverpool = Team.find_by( name: 'Liverpool FC' )
|
269
420
|
|
270
|
-
puts liverpool.
|
421
|
+
puts liverpool.matches.count #=> 1025
|
271
422
|
|
272
|
-
|
273
|
-
puts
|
274
|
-
puts
|
275
|
-
puts
|
423
|
+
m = liverpool.matches.first
|
424
|
+
puts m.team1.title #=> Liverpool FC
|
425
|
+
puts m.team2.title #=> Sheffield Wednesday FC
|
426
|
+
puts m.score_str #=> 2 - 0
|
276
427
|
|
277
428
|
|
278
429
|
## Let's try the English Premier League 2019/20
|
279
430
|
|
280
431
|
pl = Event.find_by( key: 'eng.1.2019/20' )
|
281
432
|
|
282
|
-
puts pl.
|
433
|
+
puts pl.matches.count #=> 288
|
283
434
|
|
284
|
-
|
285
|
-
puts
|
286
|
-
puts
|
287
|
-
puts
|
435
|
+
m = pl.matches.first
|
436
|
+
puts m.team1.title #=> Liverpool FC
|
437
|
+
puts m.team2.title #=> Norwich City FC
|
438
|
+
puts m.score_str #=> 4 - 1
|
288
439
|
|
289
440
|
# and so on
|
290
441
|
```
|
@@ -293,9 +444,21 @@ That's it. Enjoy the beautiful game.
|
|
293
444
|
|
294
445
|
|
295
446
|
|
447
|
+
## Installation
|
448
|
+
|
449
|
+
Use
|
450
|
+
|
451
|
+
gem install footballdata-12xpert
|
452
|
+
|
453
|
+
or add to your Gemfile
|
454
|
+
|
455
|
+
gem 'footballdata-12xpert'
|
456
|
+
|
457
|
+
|
458
|
+
|
296
459
|
## License
|
297
460
|
|
298
|
-
The `
|
461
|
+
The `footballdata-12xpert` scripts are dedicated to the public domain.
|
299
462
|
Use it as you please with no restrictions whatsoever.
|
300
463
|
|
301
464
|
|
data/lib/footballdata-12xpert.rb
CHANGED
@@ -14,128 +14,12 @@ require 'footballdata-12xpert/version' # let version always go first
|
|
14
14
|
require 'footballdata-12xpert/config'
|
15
15
|
require 'footballdata-12xpert/download'
|
16
16
|
require 'footballdata-12xpert/convert'
|
17
|
-
|
18
|
-
###
|
19
|
-
## add alternate aliases - why? why not?
|
20
|
-
Footballdata12Xpert = Footballdata12xpert
|
21
|
-
Footballdata_12xpert = Footballdata12xpert
|
22
|
-
Footballdata_12Xpert = Footballdata12xpert
|
23
|
-
|
17
|
+
require 'footballdata-12xpert/import'
|
24
18
|
|
25
19
|
|
26
20
|
|
27
21
|
module Footballdata12xpert
|
28
22
|
|
29
|
-
|
30
|
-
def self.import( *args, dir: './dl' )
|
31
|
-
|
32
|
-
country_keys = args ## countries to include / fetch - optinal
|
33
|
-
|
34
|
-
FOOTBALLDATA_SOURCES.each do |country_key, country_sources|
|
35
|
-
if country_keys.empty? || country_keys.include?( country_key )
|
36
|
-
Footballdata.import_season_by_season( country_key, country_sources, dir: dir )
|
37
|
-
else
|
38
|
-
## skipping country
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
FOOTBALLDATA_SOURCES_II.each do |country_key, country_basename|
|
43
|
-
if country_keys.empty? || country_keys.include?( country_key )
|
44
|
-
Footballdata.import_all_seasons( country_key, country_basename, dir: dir )
|
45
|
-
else
|
46
|
-
## skipping country
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end # method import
|
50
|
-
|
51
|
-
class << self
|
52
|
-
alias_method :load, :import
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
def self.import_season_by_season( country_key, sources, dir: )
|
58
|
-
|
59
|
-
## todo/check: make sure timezones entry for country_key exists!!! what results with nil/24.0 ??
|
60
|
-
fix_date_converter = ->(row) { fix_date( row, FOOTBALLDATA_TIMEZONES[country_key]/24.0 ) }
|
61
|
-
|
62
|
-
sources.each do |rec|
|
63
|
-
season_key = rec[0] ## note: dirname is season_key e.g. 2011-12 etc.
|
64
|
-
basenames = rec[1] ## e.g. E1,E2,etc.
|
65
|
-
|
66
|
-
basenames.each do |basename|
|
67
|
-
|
68
|
-
path = "#{dir}/#{season_key}/#{basename}.csv"
|
69
|
-
|
70
|
-
league_key = FOOTBALLDATA_LEAGUES[basename] ## e.g.: eng.1, fr.1, fr.2 etc.
|
71
|
-
if league_key.nil?
|
72
|
-
puts "** !!! ERROR !!! league key missing for >#{basename}<; sorry - please add"
|
73
|
-
exit 1
|
74
|
-
end
|
75
|
-
|
76
|
-
country, league = find_or_create_country_and_league( league_key )
|
77
|
-
|
78
|
-
season = SportDb::Importer::Season.find_or_create_builtin( season_key )
|
79
|
-
|
80
|
-
puts "path: #{path}"
|
81
|
-
|
82
|
-
matches = CsvMatchReader.read( path, converters: fix_date_converter )
|
83
|
-
|
84
|
-
update_matches_txt( matches,
|
85
|
-
league: league,
|
86
|
-
season: season )
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end # method import_season_by_season
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
def self.import_all_seasons( country_key, basename, dir: )
|
94
|
-
|
95
|
-
col = 'Season'
|
96
|
-
path = "#{dir}/#{basename}.csv"
|
97
|
-
|
98
|
-
season_keys = CsvMatchSplitter.find_seasons( path, col: col )
|
99
|
-
pp season_keys
|
100
|
-
|
101
|
-
## note: assume always first level/tier league for now
|
102
|
-
league_key = "#{country_key}.1"
|
103
|
-
country, league = find_or_create_country_and_league( league_key )
|
104
|
-
|
105
|
-
## todo/check: make sure timezones entry for country_key exists!!! what results with nil/24.0 ??
|
106
|
-
fix_date_converter = ->(row) { fix_date( row, FOOTBALLDATA_TIMEZONES[country_key]/24.0 ) }
|
107
|
-
|
108
|
-
season_keys.each do |season_key|
|
109
|
-
season = SportDb::Importer::Season.find_or_create_builtin( season_key )
|
110
|
-
|
111
|
-
matches = CsvMatchReader.read( path, filters: { col => season_key },
|
112
|
-
converters: fix_date_converter )
|
113
|
-
|
114
|
-
pp matches[0..2]
|
115
|
-
pp matches.size
|
116
|
-
|
117
|
-
update_matches_txt( matches,
|
118
|
-
league: league,
|
119
|
-
season: season )
|
120
|
-
end
|
121
|
-
end # method import_all_seasons
|
122
|
-
|
123
|
-
|
124
|
-
###
|
125
|
-
## helper for country and league db record
|
126
|
-
def self.find_or_create_country_and_league( league_key )
|
127
|
-
country_key, level = league_key.split( '.' )
|
128
|
-
country = SportDb::Importer::Country.find_or_create_builtin!( country_key )
|
129
|
-
|
130
|
-
league_auto_name = "#{country.name} #{level}" ## "fallback" auto-generated league name
|
131
|
-
pp league_auto_name
|
132
|
-
league = SportDb::Importer::League.find_or_create( league_key,
|
133
|
-
name: league_auto_name,
|
134
|
-
country_id: country.id )
|
135
|
-
|
136
|
-
[country, league]
|
137
|
-
end
|
138
|
-
|
139
23
|
## helper to fix dates to use local timezone (and not utc/london time)
|
140
24
|
def self.fix_date( row, offset )
|
141
25
|
return row if row['Time'].nil? ## note: time (column) required for fix
|
@@ -159,10 +43,15 @@ def self.fix_date( row, offset )
|
|
159
43
|
row ## return row for possible pipelining - why? why not?
|
160
44
|
end
|
161
45
|
|
46
|
+
end ## module Footballdata12xpert
|
162
47
|
|
163
48
|
|
164
|
-
end ## module Footballdata12xpert
|
165
49
|
|
50
|
+
###
|
51
|
+
## add alternate aliases - why? why not?
|
52
|
+
Footballdata12Xpert = Footballdata12xpert
|
53
|
+
Footballdata_12xpert = Footballdata12xpert
|
54
|
+
Footballdata_12Xpert = Footballdata12xpert
|
166
55
|
|
167
56
|
|
168
57
|
puts Footballdata12xpert.banner # say hello
|
@@ -87,225 +87,225 @@ SOURCES_I =
|
|
87
87
|
[ '1995/96', %w(D1 D2) ],
|
88
88
|
[ '1994/95', %w(D1 D2) ],
|
89
89
|
[ '1993/94', %w(D1 D2) ]],
|
90
|
-
it: [[ '2020
|
91
|
-
[ '2019
|
92
|
-
[ '2018
|
93
|
-
[ '2017
|
94
|
-
[ '2016
|
95
|
-
[ '2015
|
96
|
-
[ '2014
|
97
|
-
[ '2013
|
98
|
-
[ '2012
|
99
|
-
[ '2011
|
100
|
-
[ '2010
|
101
|
-
[ '2009
|
102
|
-
[ '2008
|
103
|
-
[ '2007
|
104
|
-
[ '2006
|
105
|
-
[ '2005
|
106
|
-
[ '2004
|
107
|
-
[ '2003
|
108
|
-
[ '2002
|
109
|
-
[ '2001
|
110
|
-
[ '2000
|
111
|
-
[ '1999
|
112
|
-
[ '1998
|
113
|
-
[ '1997
|
114
|
-
[ '1996
|
115
|
-
[ '1995
|
116
|
-
[ '1994
|
117
|
-
[ '1993
|
118
|
-
es: [[ '2020
|
119
|
-
[ '2019
|
120
|
-
[ '2018
|
121
|
-
[ '2017
|
122
|
-
[ '2016
|
123
|
-
[ '2015
|
124
|
-
[ '2014
|
125
|
-
[ '2013
|
126
|
-
[ '2012
|
127
|
-
[ '2011
|
128
|
-
[ '2010
|
129
|
-
[ '2009
|
130
|
-
[ '2008
|
131
|
-
[ '2007
|
132
|
-
[ '2006
|
133
|
-
[ '2005
|
134
|
-
[ '2004
|
135
|
-
[ '2003
|
136
|
-
[ '2002
|
137
|
-
[ '2001
|
138
|
-
[ '2000
|
139
|
-
[ '1999
|
140
|
-
[ '1998
|
141
|
-
[ '1997
|
142
|
-
[ '1996
|
143
|
-
[ '1995
|
144
|
-
[ '1994
|
145
|
-
[ '1993
|
146
|
-
fr: [[ '2020
|
147
|
-
[ '2019
|
148
|
-
[ '2018
|
149
|
-
[ '2017
|
150
|
-
[ '2016
|
151
|
-
[ '2015
|
152
|
-
[ '2014
|
153
|
-
[ '2013
|
154
|
-
[ '2012
|
155
|
-
[ '2011
|
156
|
-
[ '2010
|
157
|
-
[ '2009
|
158
|
-
[ '2008
|
159
|
-
[ '2007
|
160
|
-
[ '2006
|
161
|
-
[ '2005
|
162
|
-
[ '2004
|
163
|
-
[ '2003
|
164
|
-
[ '2002
|
165
|
-
[ '2001
|
166
|
-
[ '2000
|
167
|
-
[ '1999
|
168
|
-
[ '1998
|
169
|
-
[ '1997
|
170
|
-
[ '1996
|
171
|
-
[ '1995
|
172
|
-
[ '1994
|
173
|
-
[ '1993
|
174
|
-
nl: [[ '2020
|
175
|
-
[ '2019
|
176
|
-
[ '2018
|
177
|
-
[ '2017
|
178
|
-
[ '2016
|
179
|
-
[ '2015
|
180
|
-
[ '2014
|
181
|
-
[ '2013
|
182
|
-
[ '2012
|
183
|
-
[ '2011
|
184
|
-
[ '2010
|
185
|
-
[ '2009
|
186
|
-
[ '2008
|
187
|
-
[ '2007
|
188
|
-
[ '2006
|
189
|
-
[ '2005
|
190
|
-
[ '2004
|
191
|
-
[ '2003
|
192
|
-
[ '2002
|
193
|
-
[ '2001
|
194
|
-
[ '2000
|
195
|
-
[ '1999
|
196
|
-
[ '1998
|
197
|
-
[ '1997
|
198
|
-
[ '1996
|
199
|
-
[ '1995
|
200
|
-
[ '1994
|
201
|
-
[ '1993
|
202
|
-
be: [[ '2020
|
203
|
-
[ '2019
|
204
|
-
[ '2018
|
205
|
-
[ '2017
|
206
|
-
[ '2016
|
207
|
-
[ '2015
|
208
|
-
[ '2014
|
209
|
-
[ '2013
|
210
|
-
[ '2012
|
211
|
-
[ '2011
|
212
|
-
[ '2010
|
213
|
-
[ '2009
|
214
|
-
[ '2008
|
215
|
-
[ '2007
|
216
|
-
[ '2006
|
217
|
-
[ '2005
|
218
|
-
[ '2004
|
219
|
-
[ '2003
|
220
|
-
[ '2002
|
221
|
-
[ '2001
|
222
|
-
[ '2000
|
223
|
-
[ '1999
|
224
|
-
[ '1998
|
225
|
-
[ '1997
|
226
|
-
[ '1996
|
227
|
-
[ '1995
|
228
|
-
pt: [[ '2020
|
229
|
-
[ '2019
|
230
|
-
[ '2018
|
231
|
-
[ '2017
|
232
|
-
[ '2016
|
233
|
-
[ '2015
|
234
|
-
[ '2014
|
235
|
-
[ '2013
|
236
|
-
[ '2012
|
237
|
-
[ '2011
|
238
|
-
[ '2010
|
239
|
-
[ '2009
|
240
|
-
[ '2008
|
241
|
-
[ '2007
|
242
|
-
[ '2006
|
243
|
-
[ '2005
|
244
|
-
[ '2004
|
245
|
-
[ '2003
|
246
|
-
[ '2002
|
247
|
-
[ '2001
|
248
|
-
[ '2000
|
249
|
-
[ '1999
|
250
|
-
[ '1998
|
251
|
-
[ '1997
|
252
|
-
[ '1996
|
253
|
-
[ '1995
|
254
|
-
[ '1994
|
255
|
-
tr: [[ '2020
|
256
|
-
[ '2019
|
257
|
-
[ '2018
|
258
|
-
[ '2017
|
259
|
-
[ '2016
|
260
|
-
[ '2015
|
261
|
-
[ '2014
|
262
|
-
[ '2013
|
263
|
-
[ '2012
|
264
|
-
[ '2011
|
265
|
-
[ '2010
|
266
|
-
[ '2009
|
267
|
-
[ '2008
|
268
|
-
[ '2007
|
269
|
-
[ '2006
|
270
|
-
[ '2005
|
271
|
-
[ '2004
|
272
|
-
[ '2003
|
273
|
-
[ '2002
|
274
|
-
[ '2001
|
275
|
-
[ '2000
|
276
|
-
[ '1999
|
277
|
-
[ '1998
|
278
|
-
[ '1997
|
279
|
-
[ '1996
|
280
|
-
[ '1995
|
281
|
-
[ '1994
|
282
|
-
gr: [[ '2020
|
283
|
-
[ '2019
|
284
|
-
[ '2018
|
285
|
-
[ '2017
|
286
|
-
[ '2016
|
287
|
-
[ '2015
|
288
|
-
[ '2014
|
289
|
-
[ '2013
|
290
|
-
[ '2012
|
291
|
-
[ '2011
|
292
|
-
[ '2010
|
293
|
-
[ '2009
|
294
|
-
[ '2008
|
295
|
-
[ '2007
|
296
|
-
[ '2006
|
297
|
-
[ '2005
|
298
|
-
[ '2004
|
299
|
-
[ '2003
|
300
|
-
[ '2002
|
301
|
-
[ '2001
|
302
|
-
[ '2000
|
303
|
-
[ '1999
|
304
|
-
[ '1998
|
305
|
-
[ '1997
|
306
|
-
[ '1996
|
307
|
-
[ '1995
|
308
|
-
[ '1994
|
90
|
+
it: [[ '2020/21', %w(I1 I2) ],
|
91
|
+
[ '2019/20', %w(I1 I2) ],
|
92
|
+
[ '2018/19', %w(I1 I2) ],
|
93
|
+
[ '2017/18', %w(I1 I2) ],
|
94
|
+
[ '2016/17', %w(I1 I2) ],
|
95
|
+
[ '2015/16', %w(I1 I2) ],
|
96
|
+
[ '2014/15', %w(I1 I2) ],
|
97
|
+
[ '2013/14', %w(I1 I2) ],
|
98
|
+
[ '2012/13', %w(I1 I2) ],
|
99
|
+
[ '2011/12', %w(I1 I2) ],
|
100
|
+
[ '2010/11', %w(I1 I2) ],
|
101
|
+
[ '2009/10', %w(I1 I2) ],
|
102
|
+
[ '2008/09', %w(I1 I2) ],
|
103
|
+
[ '2007/08', %w(I1 I2) ],
|
104
|
+
[ '2006/07', %w(I1 I2) ],
|
105
|
+
[ '2005/06', %w(I1 I2) ],
|
106
|
+
[ '2004/05', %w(I1 I2) ],
|
107
|
+
[ '2003/04', %w(I1 I2) ],
|
108
|
+
[ '2002/03', %w(I1 I2) ],
|
109
|
+
[ '2001/02', %w(I1 I2) ],
|
110
|
+
[ '2000/01', %w(I1 I2) ],
|
111
|
+
[ '1999/00', %w(I1 I2) ],
|
112
|
+
[ '1998/99', %w(I1 I2) ],
|
113
|
+
[ '1997/98', %w(I1 I2) ],
|
114
|
+
[ '1996/97', %w(I1) ],
|
115
|
+
[ '1995/96', %w(I1) ],
|
116
|
+
[ '1994/95', %w(I1) ],
|
117
|
+
[ '1993/94', %w(I1) ]],
|
118
|
+
es: [[ '2020/21', %w(SP1 SP2) ],
|
119
|
+
[ '2019/20', %w(SP1 SP2) ],
|
120
|
+
[ '2018/19', %w(SP1 SP2) ],
|
121
|
+
[ '2017/18', %w(SP1 SP2) ],
|
122
|
+
[ '2016/17', %w(SP1 SP2) ],
|
123
|
+
[ '2015/16', %w(SP1 SP2) ],
|
124
|
+
[ '2014/15', %w(SP1 SP2) ],
|
125
|
+
[ '2013/14', %w(SP1 SP2) ],
|
126
|
+
[ '2012/13', %w(SP1 SP2) ],
|
127
|
+
[ '2011/12', %w(SP1 SP2) ],
|
128
|
+
[ '2010/11', %w(SP1 SP2) ],
|
129
|
+
[ '2009/10', %w(SP1 SP2) ],
|
130
|
+
[ '2008/09', %w(SP1 SP2) ],
|
131
|
+
[ '2007/08', %w(SP1 SP2) ],
|
132
|
+
[ '2006/07', %w(SP1 SP2) ],
|
133
|
+
[ '2005/06', %w(SP1 SP2) ],
|
134
|
+
[ '2004/05', %w(SP1 SP2) ],
|
135
|
+
[ '2003/04', %w(SP1 SP2) ],
|
136
|
+
[ '2002/03', %w(SP1 SP2) ],
|
137
|
+
[ '2001/02', %w(SP1 SP2) ],
|
138
|
+
[ '2000/01', %w(SP1 SP2) ],
|
139
|
+
[ '1999/00', %w(SP1 SP2) ],
|
140
|
+
[ '1998/99', %w(SP1 SP2) ],
|
141
|
+
[ '1997/98', %w(SP1 SP2) ],
|
142
|
+
[ '1996/97', %w(SP1 SP2) ],
|
143
|
+
[ '1995/96', %w(SP1) ],
|
144
|
+
[ '1994/95', %w(SP1) ],
|
145
|
+
[ '1993/94', %w(SP1) ]],
|
146
|
+
fr: [[ '2020/21', %w(F1 F2) ],
|
147
|
+
[ '2019/20', %w(F1 F2) ],
|
148
|
+
[ '2018/19', %w(F1 F2) ],
|
149
|
+
[ '2017/18', %w(F1 F2) ],
|
150
|
+
[ '2016/17', %w(F1 F2) ],
|
151
|
+
[ '2015/16', %w(F1 F2) ],
|
152
|
+
[ '2014/15', %w(F1 F2) ],
|
153
|
+
[ '2013/14', %w(F1 F2) ],
|
154
|
+
[ '2012/13', %w(F1 F2) ],
|
155
|
+
[ '2011/12', %w(F1 F2) ],
|
156
|
+
[ '2010/11', %w(F1 F2) ],
|
157
|
+
[ '2009/10', %w(F1 F2) ],
|
158
|
+
[ '2008/09', %w(F1 F2) ],
|
159
|
+
[ '2007/08', %w(F1 F2) ],
|
160
|
+
[ '2006/07', %w(F1 F2) ],
|
161
|
+
[ '2005/06', %w(F1 F2) ],
|
162
|
+
[ '2004/05', %w(F1 F2) ],
|
163
|
+
[ '2003/04', %w(F1 F2) ],
|
164
|
+
[ '2002/03', %w(F1 F2) ],
|
165
|
+
[ '2001/02', %w(F1 F2) ],
|
166
|
+
[ '2000/01', %w(F1 F2) ],
|
167
|
+
[ '1999/00', %w(F1 F2) ],
|
168
|
+
[ '1998/99', %w(F1 F2) ],
|
169
|
+
[ '1997/98', %w(F1 F2) ],
|
170
|
+
[ '1996/97', %w(F1 F2) ],
|
171
|
+
[ '1995/96', %w(F1) ],
|
172
|
+
[ '1994/95', %w(F1) ],
|
173
|
+
[ '1993/94', %w(F1) ]],
|
174
|
+
nl: [[ '2020/21', %w(N1) ],
|
175
|
+
[ '2019/20', %w(N1) ],
|
176
|
+
[ '2018/19', %w(N1) ],
|
177
|
+
[ '2017/18', %w(N1) ],
|
178
|
+
[ '2016/17', %w(N1) ],
|
179
|
+
[ '2015/16', %w(N1) ],
|
180
|
+
[ '2014/15', %w(N1) ],
|
181
|
+
[ '2013/14', %w(N1) ],
|
182
|
+
[ '2012/13', %w(N1) ],
|
183
|
+
[ '2011/12', %w(N1) ],
|
184
|
+
[ '2010/11', %w(N1) ],
|
185
|
+
[ '2009/10', %w(N1) ],
|
186
|
+
[ '2008/09', %w(N1) ],
|
187
|
+
[ '2007/08', %w(N1) ],
|
188
|
+
[ '2006/07', %w(N1) ],
|
189
|
+
[ '2005/06', %w(N1) ],
|
190
|
+
[ '2004/05', %w(N1) ],
|
191
|
+
[ '2003/04', %w(N1) ],
|
192
|
+
[ '2002/03', %w(N1) ],
|
193
|
+
[ '2001/02', %w(N1) ],
|
194
|
+
[ '2000/01', %w(N1) ],
|
195
|
+
[ '1999/00', %w(N1) ],
|
196
|
+
[ '1998/99', %w(N1) ],
|
197
|
+
[ '1997/98', %w(N1) ],
|
198
|
+
[ '1996/97', %w(N1) ],
|
199
|
+
[ '1995/96', %w(N1) ],
|
200
|
+
[ '1994/95', %w(N1) ],
|
201
|
+
[ '1993/94', %w(N1) ]],
|
202
|
+
be: [[ '2020/21', %w(B1) ],
|
203
|
+
[ '2019/20', %w(B1) ],
|
204
|
+
[ '2018/19', %w(B1) ],
|
205
|
+
[ '2017/18', %w(B1) ],
|
206
|
+
[ '2016/17', %w(B1) ],
|
207
|
+
[ '2015/16', %w(B1) ],
|
208
|
+
[ '2014/15', %w(B1) ],
|
209
|
+
[ '2013/14', %w(B1) ],
|
210
|
+
[ '2012/13', %w(B1) ],
|
211
|
+
[ '2011/12', %w(B1) ],
|
212
|
+
[ '2010/11', %w(B1) ],
|
213
|
+
[ '2009/10', %w(B1) ],
|
214
|
+
[ '2008/09', %w(B1) ],
|
215
|
+
[ '2007/08', %w(B1) ],
|
216
|
+
[ '2006/07', %w(B1) ],
|
217
|
+
[ '2005/06', %w(B1) ],
|
218
|
+
[ '2004/05', %w(B1) ],
|
219
|
+
[ '2003/04', %w(B1) ],
|
220
|
+
[ '2002/03', %w(B1) ],
|
221
|
+
[ '2001/02', %w(B1) ],
|
222
|
+
[ '2000/01', %w(B1) ],
|
223
|
+
[ '1999/00', %w(B1) ],
|
224
|
+
[ '1998/99', %w(B1) ],
|
225
|
+
[ '1997/98', %w(B1) ],
|
226
|
+
[ '1996/97', %w(B1) ],
|
227
|
+
[ '1995/96', %w(B1) ]],
|
228
|
+
pt: [[ '2020/21', %w(P1) ],
|
229
|
+
[ '2019/20', %w(P1) ],
|
230
|
+
[ '2018/19', %w(P1) ],
|
231
|
+
[ '2017/18', %w(P1) ],
|
232
|
+
[ '2016/17', %w(P1) ],
|
233
|
+
[ '2015/16', %w(P1) ],
|
234
|
+
[ '2014/15', %w(P1) ],
|
235
|
+
[ '2013/14', %w(P1) ],
|
236
|
+
[ '2012/13', %w(P1) ],
|
237
|
+
[ '2011/12', %w(P1) ],
|
238
|
+
[ '2010/11', %w(P1) ],
|
239
|
+
[ '2009/10', %w(P1) ],
|
240
|
+
[ '2008/09', %w(P1) ],
|
241
|
+
[ '2007/08', %w(P1) ],
|
242
|
+
[ '2006/07', %w(P1) ],
|
243
|
+
[ '2005/06', %w(P1) ],
|
244
|
+
[ '2004/05', %w(P1) ],
|
245
|
+
[ '2003/04', %w(P1) ],
|
246
|
+
[ '2002/03', %w(P1) ],
|
247
|
+
[ '2001/02', %w(P1) ],
|
248
|
+
[ '2000/01', %w(P1) ],
|
249
|
+
[ '1999/00', %w(P1) ],
|
250
|
+
[ '1998/99', %w(P1) ],
|
251
|
+
[ '1997/98', %w(P1) ],
|
252
|
+
[ '1996/97', %w(P1) ],
|
253
|
+
[ '1995/96', %w(P1) ],
|
254
|
+
[ '1994/95', %w(P1) ]],
|
255
|
+
tr: [[ '2020/21', %w(T1) ],
|
256
|
+
[ '2019/20', %w(T1) ],
|
257
|
+
[ '2018/19', %w(T1) ],
|
258
|
+
[ '2017/18', %w(T1) ],
|
259
|
+
[ '2016/17', %w(T1) ],
|
260
|
+
[ '2015/16', %w(T1) ],
|
261
|
+
[ '2014/15', %w(T1) ],
|
262
|
+
[ '2013/14', %w(T1) ],
|
263
|
+
[ '2012/13', %w(T1) ],
|
264
|
+
[ '2011/12', %w(T1) ],
|
265
|
+
[ '2010/11', %w(T1) ],
|
266
|
+
[ '2009/10', %w(T1) ],
|
267
|
+
[ '2008/09', %w(T1) ],
|
268
|
+
[ '2007/08', %w(T1) ],
|
269
|
+
[ '2006/07', %w(T1) ],
|
270
|
+
[ '2005/06', %w(T1) ],
|
271
|
+
[ '2004/05', %w(T1) ],
|
272
|
+
[ '2003/04', %w(T1) ],
|
273
|
+
[ '2002/03', %w(T1) ],
|
274
|
+
[ '2001/02', %w(T1) ],
|
275
|
+
[ '2000/01', %w(T1) ],
|
276
|
+
[ '1999/00', %w(T1) ],
|
277
|
+
[ '1998/99', %w(T1) ],
|
278
|
+
[ '1997/98', %w(T1) ],
|
279
|
+
[ '1996/97', %w(T1) ],
|
280
|
+
[ '1995/96', %w(T1) ],
|
281
|
+
[ '1994/95', %w(T1) ]],
|
282
|
+
gr: [[ '2020/21', %w(G1) ],
|
283
|
+
[ '2019/20', %w(G1) ],
|
284
|
+
[ '2018/19', %w(G1) ],
|
285
|
+
[ '2017/18', %w(G1) ],
|
286
|
+
[ '2016/17', %w(G1) ],
|
287
|
+
[ '2015/16', %w(G1) ],
|
288
|
+
[ '2014/15', %w(G1) ],
|
289
|
+
[ '2013/14', %w(G1) ],
|
290
|
+
[ '2012/13', %w(G1) ],
|
291
|
+
[ '2011/12', %w(G1) ],
|
292
|
+
[ '2010/11', %w(G1) ],
|
293
|
+
[ '2009/10', %w(G1) ],
|
294
|
+
[ '2008/09', %w(G1) ],
|
295
|
+
[ '2007/08', %w(G1) ],
|
296
|
+
[ '2006/07', %w(G1) ],
|
297
|
+
[ '2005/06', %w(G1) ],
|
298
|
+
[ '2004/05', %w(G1) ],
|
299
|
+
[ '2003/04', %w(G1) ],
|
300
|
+
[ '2002/03', %w(G1) ],
|
301
|
+
[ '2001/02', %w(G1) ],
|
302
|
+
[ '2000/01', %w(G1) ],
|
303
|
+
[ '1999/00', %w(G1) ],
|
304
|
+
[ '1998/99', %w(G1) ],
|
305
|
+
[ '1997/98', %w(G1) ],
|
306
|
+
[ '1996/97', %w(G1) ],
|
307
|
+
[ '1995/96', %w(G1) ],
|
308
|
+
[ '1994/95', %w(G1) ]]
|
309
309
|
}
|
310
310
|
|
311
311
|
## all seasons in-one-file datasets
|
@@ -417,4 +417,26 @@ TIMEZONES = {
|
|
417
417
|
jp: +9, ## Asia/Tokyo
|
418
418
|
}
|
419
419
|
|
420
|
+
|
421
|
+
##################
|
422
|
+
### config options / settings
|
423
|
+
class Configuration
|
424
|
+
#########
|
425
|
+
## nested configuration classes - use - why? why not?
|
426
|
+
class Convert
|
427
|
+
def out_dir() @out_dir || './o'; end
|
428
|
+
def out_dir=(value) @out_dir = value; end
|
429
|
+
end
|
430
|
+
|
431
|
+
def convert() @convert ||= Convert.new; end
|
432
|
+
end # class Configuration
|
433
|
+
|
434
|
+
## lets you use
|
435
|
+
## Footballdata12xpert.configure do |config|
|
436
|
+
## config.convert.out_dir = './o'
|
437
|
+
## end
|
438
|
+
|
439
|
+
def self.configure() yield( config ); end
|
440
|
+
def self.config() @config ||= Configuration.new; end
|
420
441
|
end # module Footballdata12xpert
|
442
|
+
|
@@ -85,6 +85,7 @@ class CsvMatchWriter
|
|
85
85
|
end # class CsvMatchWriter
|
86
86
|
|
87
87
|
|
88
|
+
|
88
89
|
module Footballdata12xpert
|
89
90
|
|
90
91
|
##
|
@@ -123,10 +124,6 @@ def self.convert_season_by_season( country_key, sources, start: nil )
|
|
123
124
|
|
124
125
|
start = Season.parse( start ) if start ## convert to season obj
|
125
126
|
|
126
|
-
|
127
|
-
out_dir = './o'
|
128
|
-
|
129
|
-
|
130
127
|
sources.each do |rec|
|
131
128
|
season = Season.parse( rec[0] ) ## note: dirname is season e.g. 2011-12 etc.
|
132
129
|
basenames = rec[1] ## e.g. E1,E2,etc.
|
@@ -146,7 +143,7 @@ def self.convert_season_by_season( country_key, sources, start: nil )
|
|
146
143
|
league_key = LEAGUES[basename]
|
147
144
|
league_basename = league_key ## e.g.: eng.1, fr.1, fr.2 etc.
|
148
145
|
|
149
|
-
out_path = "#{out_dir}/#{season.to_path}/#{league_basename}.csv"
|
146
|
+
out_path = "#{config.convert.out_dir}/#{season.to_path}/#{league_basename}.csv"
|
150
147
|
|
151
148
|
puts "out_path: #{out_path}"
|
152
149
|
|
@@ -166,7 +163,6 @@ def self.convert_all_seasons( country_key, basename, start: nil )
|
|
166
163
|
|
167
164
|
start = Season.parse( start ) if start ## convert to season obj
|
168
165
|
|
169
|
-
out_dir = './o'
|
170
166
|
|
171
167
|
url = all_seasons_url( basename )
|
172
168
|
|
@@ -197,7 +193,7 @@ def self.convert_all_seasons( country_key, basename, start: nil )
|
|
197
193
|
## note: assume (always) first level league for now
|
198
194
|
league_basename = "#{country_key}.1" ## e.g.: ar.1, at.1, mx.1, us.1, etc.
|
199
195
|
|
200
|
-
out_path = "#{out_dir}/#{season.to_path}/#{league_basename}.csv"
|
196
|
+
out_path = "#{config.convert.out_dir}/#{season.to_path}/#{league_basename}.csv"
|
201
197
|
|
202
198
|
CsvMatchWriter.write( out_path, matches )
|
203
199
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Footballdata12xpert
|
2
|
+
|
3
|
+
|
4
|
+
def self.import( *country_keys, start: nil )
|
5
|
+
## note: always downcase and symbolize keys (thus, allow strings too for now)
|
6
|
+
country_keys = country_keys.map {|key| key.downcase.to_sym }
|
7
|
+
|
8
|
+
## fix/todo: filter by country keys and start sesason to be (re)done
|
9
|
+
|
10
|
+
## todo/fix: use/add normalize: true option!!!!!
|
11
|
+
|
12
|
+
dir = File.expand_path( config.convert.out_dir )
|
13
|
+
puts " dir: >#{dir}<"
|
14
|
+
|
15
|
+
# SportDb.read_csv( dir )
|
16
|
+
## todo/fix: use SportDb Csv Package or such???
|
17
|
+
puts "import to be (re)done; sorry"
|
18
|
+
end # method import
|
19
|
+
|
20
|
+
|
21
|
+
end ## module Footballdata12xpert
|
data/test/test_import.rb
CHANGED
@@ -19,15 +19,15 @@ class TestImport < MiniTest::Test
|
|
19
19
|
|
20
20
|
|
21
21
|
def test_import_at
|
22
|
-
|
22
|
+
Footballdata12xpert.import( 'at' )
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_import_eng
|
26
|
-
|
26
|
+
Footballdata12xpert.import( 'eng', start: '2020/21' )
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
29
|
+
def xxx_test_import_all ## note: test disabled for now
|
30
|
+
Footballdata12xpert.import
|
31
31
|
end
|
32
32
|
|
33
33
|
end # class TestImport
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: footballdata-12xpert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/footballdata-12xpert/config.rb
|
106
106
|
- lib/footballdata-12xpert/convert.rb
|
107
107
|
- lib/footballdata-12xpert/download.rb
|
108
|
+
- lib/footballdata-12xpert/import.rb
|
108
109
|
- lib/footballdata-12xpert/version.rb
|
109
110
|
- lib/footballdata/12xpert.rb
|
110
111
|
- test/helper.rb
|