fbtxt2sqlite 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Manifest.txt +5 -0
- data/README.md +56 -0
- data/Rakefile +32 -0
- data/bin/fbtxt2sqlite +113 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 44bc1f5e70d3811934bb303075ab4cf20a283aadfd1d191b40f1714d64ca1c0c
|
4
|
+
data.tar.gz: d5a5584d418c12f5b4c398df52b4405589a8e8f96b04235bbff4d0a5a8867b8d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d0eb2bcff71b916c8a7f880537f9cc55758d2afa141681039f7dffdccbb3a1f80f3d47771bf43558ccd42adbbac674f6f0d38e989303c829471cd10a98f42d12
|
7
|
+
data.tar.gz: f33f966ae54ae114d9150cbd30f10983462996a5b205af9974e0596c8faba398b896b2eaac3fb3876901226758c23196be0e728f634a89a253517e1b6caf5535
|
data/CHANGELOG.md
ADDED
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# fbtxt2sqlite - read football.txt match schedules & more into sqlite database
|
2
|
+
|
3
|
+
|
4
|
+
* home :: [github.com/sportdb/footty](https://github.com/sportdb/footty)
|
5
|
+
* bugs :: [github.com/sportdb/footty/issues](https://github.com/sportdb/footty/issues)
|
6
|
+
* gem :: [rubygems.org/gems/fbtxt2sqlite](https://rubygems.org/gems/fbtxt2sqlite)
|
7
|
+
* rdoc :: [rubydoc.info/gems/fbtxt2sqlite](http://rubydoc.info/gems/fbtxt2sqlite)
|
8
|
+
|
9
|
+
|
10
|
+
## Step 0 - Installation Via Gems
|
11
|
+
|
12
|
+
To install the command-line tool via gems (ruby's package manager) use:
|
13
|
+
|
14
|
+
```
|
15
|
+
$ gem install fbtxt2sqlite
|
16
|
+
```
|
17
|
+
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Try in your shell / terminal:
|
22
|
+
|
23
|
+
```
|
24
|
+
$ fbtxt2sqlite -h
|
25
|
+
```
|
26
|
+
|
27
|
+
resulting in:
|
28
|
+
|
29
|
+
```
|
30
|
+
Usage: fbtxt2sqlite [options] DBPATH PATH
|
31
|
+
--verbose, --debug turn on verbose / debug output (default: false)
|
32
|
+
--seasons SEASONS turn on processing only seasons listed
|
33
|
+
```
|
34
|
+
|
35
|
+
|
36
|
+
Let's try to read in the England directory (repo), that is, all match schedules & results
|
37
|
+
in the Football.TXT format
|
38
|
+
(see [`/england`](https://github.com/openfootball/england))
|
39
|
+
that includes the Premier League, Championship, & more:
|
40
|
+
|
41
|
+
```
|
42
|
+
$ fbtxt2sqlite england.db ./england
|
43
|
+
```
|
44
|
+
|
45
|
+
resulting in an sqlite database named `./england.db` with league, team, match, & more records.
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
That's it.
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
## Questions? Comments?
|
54
|
+
|
55
|
+
Yes, you can. More than welcome.
|
56
|
+
See [Help & Support »](https://github.com/openfootball/help)
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
|
3
|
+
|
4
|
+
Hoe.spec 'fbtxt2sqlite' do
|
5
|
+
self.version = '0.0.1'
|
6
|
+
|
7
|
+
self.summary = "fbtxt2sqlite - read football.txt match schedules & more into sqlite database"
|
8
|
+
self.description = summary
|
9
|
+
|
10
|
+
self.urls = { home: 'https://github.com/sportdb/footty' }
|
11
|
+
|
12
|
+
self.author = 'Gerald Bauer'
|
13
|
+
self.email = 'gerald.bauer@gmail.com'
|
14
|
+
|
15
|
+
# switch extension to .markdown for gihub formatting
|
16
|
+
self.readme_file = 'README.md'
|
17
|
+
self.history_file = 'CHANGELOG.md'
|
18
|
+
|
19
|
+
self.licenses = ['Public Domain']
|
20
|
+
|
21
|
+
self.extra_deps = [
|
22
|
+
['sportdb-models_v2'],
|
23
|
+
## ['sportdb-quick', '>= 0.2.1'], ## pulled-in via sportdb-models_v2 already
|
24
|
+
### note - include fbtok gem for (shared) command-line helpers/machinery!!!
|
25
|
+
['fbtok', '>= 0.3.3'],
|
26
|
+
['sqlite3'],
|
27
|
+
]
|
28
|
+
|
29
|
+
self.spec_extras = {
|
30
|
+
required_ruby_version: '>= 3.1.0'
|
31
|
+
}
|
32
|
+
end
|
data/bin/fbtxt2sqlite
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
## tip: to test run:
|
4
|
+
## ruby -I ./lib bin/fbtxt2sqlite
|
5
|
+
|
6
|
+
|
7
|
+
## our own code
|
8
|
+
require 'sportdb/models_v2'
|
9
|
+
|
10
|
+
require 'fbtok' ### check if requires sportdb/quick (no need to duplicate)
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
require 'optparse'
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
args = ARGV
|
19
|
+
opts = { debug: false,
|
20
|
+
seasons: [],
|
21
|
+
}
|
22
|
+
|
23
|
+
parser = OptionParser.new do |parser|
|
24
|
+
parser.banner = "Usage: #{$PROGRAM_NAME} [options] PATH"
|
25
|
+
|
26
|
+
##
|
27
|
+
## check if git has a offline option?? (use same)
|
28
|
+
## check for other tools - why? why not?
|
29
|
+
# parser.on( "-q", "--quiet",
|
30
|
+
# "less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
|
31
|
+
# opts[:debug] = false
|
32
|
+
# end
|
33
|
+
|
34
|
+
parser.on( "--verbose", "--debug",
|
35
|
+
"turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
|
36
|
+
opts[:debug] = true
|
37
|
+
end
|
38
|
+
|
39
|
+
parser.on( "--seasons SEASONS",
|
40
|
+
"turn on processing only seasons (default: #{!opts[:seasons].empty?}" ) do |seasons|
|
41
|
+
pp seasons
|
42
|
+
seasons = seasons.split( /[, ]/ )
|
43
|
+
seasons = seasons.map {|season| Season.parse(season) }
|
44
|
+
opts[:seasons] = seasons
|
45
|
+
end
|
46
|
+
end
|
47
|
+
parser.parse!( args )
|
48
|
+
|
49
|
+
|
50
|
+
puts "OPTS:"
|
51
|
+
p opts
|
52
|
+
puts "ARGV:"
|
53
|
+
p args
|
54
|
+
|
55
|
+
|
56
|
+
## note - first arg is database
|
57
|
+
if args.size < 1
|
58
|
+
puts "!! ERROR - sqlite database path required"
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
|
62
|
+
dbpath = args.shift
|
63
|
+
|
64
|
+
paths = if args.empty?
|
65
|
+
['/sports/openfootball/euro/2021--europe/euro.txt']
|
66
|
+
else
|
67
|
+
args
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
if opts[:debug]
|
72
|
+
## SportDb::QuickMatchReader.debug = true
|
73
|
+
SportDb::MatchParser.debug = true
|
74
|
+
else
|
75
|
+
## SportDb::QuickMatchReader.debug = false
|
76
|
+
SportDb::MatchParser.debug = false
|
77
|
+
LogUtils::Logger.root.level = :info
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
SportDbV2.open( dbpath )
|
83
|
+
SportDbV2.auto_migrate!
|
84
|
+
SportDbV2.tables
|
85
|
+
|
86
|
+
|
87
|
+
paths.each_with_index do |path,i|
|
88
|
+
if Dir.exist?( path )
|
89
|
+
puts "==> reading dir [#{i+1}/#{paths.size}] >#{path}<..."
|
90
|
+
|
91
|
+
datafiles = SportDb::Parser::Opts._find( path, seasons: opts[:seasons] )
|
92
|
+
pp datafiles
|
93
|
+
puts " #{datafiles.size} datafile(s)"
|
94
|
+
|
95
|
+
datafiles.each_with_index do |datafile,j|
|
96
|
+
puts " ... reading file [#{j+1}/#{datafiles.size}] >#{datafile}<..."
|
97
|
+
SportDbV2::MatchReader.read( datafile )
|
98
|
+
end
|
99
|
+
elsif File.exist?( path )
|
100
|
+
puts "==> reading file [#{i+1}/#{paths.size}] >#{path}<..."
|
101
|
+
SportDbV2::MatchReader.read( path )
|
102
|
+
else ## not a file or dir repprt errr
|
103
|
+
raise ArgumentError, "file/dir does NOT exist - #{path}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
puts "---"
|
109
|
+
SportDbV2.tables
|
110
|
+
|
111
|
+
|
112
|
+
puts "bye"
|
113
|
+
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fbtxt2sqlite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerald Bauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sportdb-models_v2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fbtok
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.3.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.3.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '7'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '4.0'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '7'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: hoe
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '4.2'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '4.2'
|
89
|
+
description: fbtxt2sqlite - read football.txt match schedules & more into sqlite database
|
90
|
+
email: gerald.bauer@gmail.com
|
91
|
+
executables:
|
92
|
+
- fbtxt2sqlite
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files:
|
95
|
+
- CHANGELOG.md
|
96
|
+
- Manifest.txt
|
97
|
+
- README.md
|
98
|
+
files:
|
99
|
+
- CHANGELOG.md
|
100
|
+
- Manifest.txt
|
101
|
+
- README.md
|
102
|
+
- Rakefile
|
103
|
+
- bin/fbtxt2sqlite
|
104
|
+
homepage: https://github.com/sportdb/footty
|
105
|
+
licenses:
|
106
|
+
- Public Domain
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options:
|
110
|
+
- "--main"
|
111
|
+
- README.md
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 3.1.0
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubygems_version: 3.5.22
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: fbtxt2sqlite - read football.txt match schedules & more into sqlite database
|
129
|
+
test_files: []
|