gtfs_df 0.10.0 → 0.10.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 +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/gtfs_df/reader.rb +15 -1
- data/lib/gtfs_df/version.rb +1 -1
- metadata +1 -6
- data/examples/split-by-agency/.gitignore +0 -1
- data/examples/split-by-agency/Gemfile +0 -5
- data/examples/split-by-agency/Gemfile.lock +0 -54
- data/examples/split-by-agency/README.md +0 -26
- data/examples/split-by-agency/split_by_agency.rb +0 -63
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5200ee072c53d95cdb96af3fc8e0f15f9a15e2cc22684b5c9b2b2eeb4c103c8a
|
|
4
|
+
data.tar.gz: 843492a5f86c595d48431edcf2decd800debc1ead5dd2df0e77d89bf920c01ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be450515810d21760afbff3800887e3e5605052bd52eaf7df81951d6193c141dc9487d6b566b9caae5bd44a990051f54907ded2fa619406018afb32df8f3209a
|
|
7
|
+
data.tar.gz: b6efebb9c5190777a3698a2b747b8528a7a72598c96254fbc7c9ead11aceaa72de75d2a95fb5a4c60745a0aacb0234108e4e5c663650bd5e0d71b858881325ca
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [0.10.1] - 2026-03-18
|
|
2
|
+
|
|
3
|
+
### 🐛 Bug Fixes
|
|
4
|
+
|
|
5
|
+
- Sanitize feed input
|
|
6
|
+
|
|
7
|
+
### ⚙️ Miscellaneous Tasks
|
|
8
|
+
|
|
9
|
+
- Normalize platforms
|
|
10
|
+
- Ignore the examples folder on publishing
|
|
1
11
|
## [0.10.0] - 2026-03-06
|
|
2
12
|
|
|
3
13
|
### 🚀 Features
|
|
@@ -9,6 +19,10 @@
|
|
|
9
19
|
### 🐛 Bug Fixes
|
|
10
20
|
|
|
11
21
|
- Service dates and busiest week fixes
|
|
22
|
+
|
|
23
|
+
### ⚙️ Miscellaneous Tasks
|
|
24
|
+
|
|
25
|
+
- Bump version to 0.10.0
|
|
12
26
|
## [0.9.3] - 2026-02-27
|
|
13
27
|
|
|
14
28
|
### 🐛 Bug Fixes
|
data/lib/gtfs_df/reader.rb
CHANGED
|
@@ -10,10 +10,18 @@ module GtfsDf
|
|
|
10
10
|
def self.load_from_zip(zip_path, parse_times: false)
|
|
11
11
|
data = nil
|
|
12
12
|
|
|
13
|
+
relevant_files = GtfsDf::Feed::GTFS_FILES
|
|
14
|
+
.map { |name| "#{name}.txt" }
|
|
15
|
+
.to_set
|
|
16
|
+
|
|
13
17
|
Dir.mktmpdir do |tmpdir|
|
|
14
18
|
Zip::File.open(zip_path) do |zip_file|
|
|
15
19
|
zip_file.each do |entry|
|
|
16
|
-
|
|
20
|
+
# We're skipping:
|
|
21
|
+
# - directories
|
|
22
|
+
# - unrelated files
|
|
23
|
+
# - empty feed files
|
|
24
|
+
next unless entry.file? && relevant_files.include?(entry.name) && has_header?(entry)
|
|
17
25
|
entry.extract(destination_directory: tmpdir)
|
|
18
26
|
end
|
|
19
27
|
end
|
|
@@ -45,5 +53,11 @@ module GtfsDf
|
|
|
45
53
|
schema_class_name = gtfs_file.split("_").map(&:capitalize).join
|
|
46
54
|
GtfsDf::Schema.const_get(schema_class_name).new(path).df
|
|
47
55
|
end
|
|
56
|
+
|
|
57
|
+
private_class_method def self.has_header?(zip_entry)
|
|
58
|
+
zip_entry.get_input_stream.readline.strip != ""
|
|
59
|
+
rescue
|
|
60
|
+
false
|
|
61
|
+
end
|
|
48
62
|
end
|
|
49
63
|
end
|
data/lib/gtfs_df/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gtfs_df
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.10.
|
|
4
|
+
version: 0.10.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Mejorado
|
|
@@ -90,11 +90,6 @@ files:
|
|
|
90
90
|
- devenv.lock
|
|
91
91
|
- devenv.nix
|
|
92
92
|
- devenv.yaml
|
|
93
|
-
- examples/split-by-agency/.gitignore
|
|
94
|
-
- examples/split-by-agency/Gemfile
|
|
95
|
-
- examples/split-by-agency/Gemfile.lock
|
|
96
|
-
- examples/split-by-agency/README.md
|
|
97
|
-
- examples/split-by-agency/split_by_agency.rb
|
|
98
93
|
- lib/gtfs_df.rb
|
|
99
94
|
- lib/gtfs_df/base_gtfs_table.rb
|
|
100
95
|
- lib/gtfs_df/feed.rb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
output/
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: ../..
|
|
3
|
-
specs:
|
|
4
|
-
gtfs_df (0.10.0)
|
|
5
|
-
networkx (~> 0.4)
|
|
6
|
-
polars-df (~> 0.22, < 0.24)
|
|
7
|
-
rubyzip (>= 3.0, < 4.0)
|
|
8
|
-
|
|
9
|
-
GEM
|
|
10
|
-
remote: https://gem.coop/
|
|
11
|
-
specs:
|
|
12
|
-
bigdecimal (4.0.1)
|
|
13
|
-
json (2.18.0)
|
|
14
|
-
matrix (0.4.3)
|
|
15
|
-
networkx (0.4.0)
|
|
16
|
-
matrix (~> 0.4)
|
|
17
|
-
rb_heap (~> 1.0)
|
|
18
|
-
optparse (0.8.1)
|
|
19
|
-
polars-df (0.23.0-aarch64-linux)
|
|
20
|
-
bigdecimal
|
|
21
|
-
polars-df (0.23.0-aarch64-linux-musl)
|
|
22
|
-
bigdecimal
|
|
23
|
-
polars-df (0.23.0-arm64-darwin)
|
|
24
|
-
bigdecimal
|
|
25
|
-
polars-df (0.23.0-x86_64-darwin)
|
|
26
|
-
bigdecimal
|
|
27
|
-
polars-df (0.23.0-x86_64-linux)
|
|
28
|
-
bigdecimal
|
|
29
|
-
polars-df (0.23.0-x86_64-linux-musl)
|
|
30
|
-
bigdecimal
|
|
31
|
-
rb_heap (1.1.0)
|
|
32
|
-
rubyzip (3.2.2)
|
|
33
|
-
unicode-display_width (3.2.0)
|
|
34
|
-
unicode-emoji (~> 4.1)
|
|
35
|
-
unicode-emoji (4.2.0)
|
|
36
|
-
whirly (0.4.0)
|
|
37
|
-
json
|
|
38
|
-
unicode-display_width (>= 1.1)
|
|
39
|
-
|
|
40
|
-
PLATFORMS
|
|
41
|
-
aarch64-linux
|
|
42
|
-
aarch64-linux-musl
|
|
43
|
-
arm64-darwin
|
|
44
|
-
x86_64-darwin
|
|
45
|
-
x86_64-linux
|
|
46
|
-
x86_64-linux-musl
|
|
47
|
-
|
|
48
|
-
DEPENDENCIES
|
|
49
|
-
gtfs_df!
|
|
50
|
-
optparse
|
|
51
|
-
whirly
|
|
52
|
-
|
|
53
|
-
BUNDLED WITH
|
|
54
|
-
2.6.9
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Split GTFS by Agency Example
|
|
2
|
-
|
|
3
|
-
This example demonstrates how to split a GTFS zip file into multiple files, one for each specified `agency_id`, using the `gtfs_df` Ruby gem.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
bundle install
|
|
9
|
-
ruby split_by_agency.rb -i <input-gtfs.zip> --ids agency1,agency2
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
- The output files will be written to the `output/` directory, named `<agency_id>.zip`.
|
|
13
|
-
|
|
14
|
-
## Options
|
|
15
|
-
- `-i`, `--input PATH` — Path to the input GTFS zip file
|
|
16
|
-
- `--ids IDS` — Comma-separated list of agency IDs to extract
|
|
17
|
-
|
|
18
|
-
## Example
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
ruby split_by_agency.rb -i ../../spec/fixtures/sample_gtfs.zip --ids DTA,OTA
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
This is a port of the [original Python script](https://gist.github.com/davidmh/f51e5d93a9213e0e606a43167ff87403) using Partridge.
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "optparse"
|
|
5
|
-
require "fileutils"
|
|
6
|
-
require "gtfs_df"
|
|
7
|
-
require "whirly"
|
|
8
|
-
|
|
9
|
-
options = {}
|
|
10
|
-
OptionParser.new do |opts|
|
|
11
|
-
opts.banner = "Usage: split_by_agency.rb -i <input-gtfs.zip> --ids NUMBERS"
|
|
12
|
-
|
|
13
|
-
opts.on("-i", "--input PATH", "Path to the input GTFS file") do |v|
|
|
14
|
-
options[:input] = v
|
|
15
|
-
end
|
|
16
|
-
opts.on("--ids IDS", "Comma-separated list of agency_ids") do |v|
|
|
17
|
-
options[:ids] = v
|
|
18
|
-
end
|
|
19
|
-
end.parse!
|
|
20
|
-
|
|
21
|
-
unless options[:input] && options[:ids]
|
|
22
|
-
warn "Both --input and --ids are required."
|
|
23
|
-
exit 1
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
input_path = File.expand_path(options[:input])
|
|
27
|
-
agency_ids = options[:ids].split(",")
|
|
28
|
-
output_dir = File.expand_path("./output", __dir__)
|
|
29
|
-
FileUtils.mkdir_p(output_dir)
|
|
30
|
-
|
|
31
|
-
feed = nil
|
|
32
|
-
|
|
33
|
-
Whirly.configure spinner: "dots", stop: "✓"
|
|
34
|
-
|
|
35
|
-
Whirly.start do
|
|
36
|
-
Whirly.status = "Loading"
|
|
37
|
-
|
|
38
|
-
start_time = Time.now
|
|
39
|
-
feed = GtfsDf::Reader.load_from_zip(input_path)
|
|
40
|
-
elapsed = Time.now - start_time
|
|
41
|
-
|
|
42
|
-
Whirly.status = "Loaded (#{elapsed.round(2)}s)"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
agency_ids.each do |agency_id|
|
|
46
|
-
Whirly.start do
|
|
47
|
-
output_path = File.join(output_dir, "#{agency_id}.zip")
|
|
48
|
-
|
|
49
|
-
start_time = Time.now
|
|
50
|
-
|
|
51
|
-
Whirly.status = "-> #{agency_id} filtering..."
|
|
52
|
-
filtered_feed = feed.filter({"agency" => {"agency_id" => agency_id}})
|
|
53
|
-
|
|
54
|
-
Whirly.status = "-> #{agency_id} writing..."
|
|
55
|
-
GtfsDf::Writer.write_to_zip(filtered_feed, output_path)
|
|
56
|
-
|
|
57
|
-
elapsed = Time.now - start_time
|
|
58
|
-
|
|
59
|
-
Whirly.status = "-> #{agency_id}.zip (#{elapsed.round(2)}s)"
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
puts "✓ Done, all files are stored in the output/ directory"
|