Skip to content

Query language

--where filters the records acted on by read, update, and delete. It is a small expression language, not SQL: there are no joins, no sub-queries, no parentheses, and no aggregations. Everything is a boolean expression over the columns of a single GTFS file.

expression := filter | filter " OR " expression
filter := term | term " AND " filter
term := field operator value
operator := "=" | "!=" | ">" | ">=" | "<" | "<=" | " LIKE "

AND binds tighter than OR. There is no way to override precedence — parentheses are not supported.

OperatorMeaningExample
=Equalstop_id=S01
!=Not equalroute_type!=3
>Greater than (string-compared)stop_sequence>10
>=Greater or equalarrival_time>=06:00:00
<Less thandate<20260101
<=Less or equalroute_type<=4
LIKESQL-style pattern matchstop_name LIKE Gare%

Comparison operators perform a plain string comparison. For numeric fields (like stop_sequence or route_type) this matches the intuitive order as long as values are zero-padded or unsigned; check your data before using < / > on free-form fields.

LIKE matches against a pattern where:

  • % stands for any sequence of characters (including empty).
  • _ stands for exactly one character.
PatternMatches
Gare%Gare Centrale, Gare du Nord, Gare
%NordGare du Nord, Nord
%bus%Any value containing bus
stop___stop001, stopABC — exactly 4+3 = 7 chars

Whitespace around operators is optional and does not change meaning:

stop_id=S01
stop_id = S01
stop_id = S01

When a value contains AND, OR, or whitespace that could be mistaken for a keyword, wrap it in backticks:

stop_name=`Gare du Nord AND Est`
route_long_name=`Express 747 OR 748`

Inside backticks, the content is taken verbatim. Backticks are not required for simple values.

AND and OR let you compose filters. AND takes higher precedence, so

a=1 AND b=2 OR c=3

parses as (a=1 AND b=2) OR c=3.

Since parentheses are not supported, express a=1 AND (b=2 OR c=3) by splitting the work across commands or by narrowing it to the equivalent two-branch OR of ANDs:

a=1 AND b=2 OR a=1 AND c=3
Terminal window
gapline read stops --where "stop_id=S01"
gapline read routes --where "route_type!=3"
Terminal window
gapline read stop-times --where "stop_sequence>10 AND stop_sequence<20"
Terminal window
gapline read stops --where "stop_name LIKE Gare%"
gapline read stops --where "stop_name LIKE %Nord"
Terminal window
gapline read routes --where "route_type=3 OR route_type=1"
Terminal window
gapline read stops --where 'stop_name=`Gare du Nord AND Est`'

Single quotes around the whole expression (in the shell) protect the backticks from your shell’s own history-expansion or command-substitution rules.

Common parser errors and what they mean:

ErrorCause
invalid expression: ''--where "". Pass an expression or drop the flag.
unexpected logical operator without expressionsAND …, … OR, or a dangling … AND AND ….
empty field name=value. The left side of an operator is missing.
empty value for field 'stop_id'stop_id=. The right side of an operator is missing.
unknown operator in '…'Typo like stop_id == S01 or stop_id LIKES Gare%.
unknown field 'stop_naem'Field name is not a column of the target file. The error lists valid names.