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.
Grammar
Section titled “Grammar”expression := filter | filter " OR " expressionfilter := term | term " AND " filterterm := field operator value
operator := "=" | "!=" | ">" | ">=" | "<" | "<=" | " LIKE "AND binds tighter than OR. There is no way to override precedence — parentheses are not supported.
Operators
Section titled “Operators”| Operator | Meaning | Example |
|---|---|---|
= | Equal | stop_id=S01 |
!= | Not equal | route_type!=3 |
> | Greater than (string-compared) | stop_sequence>10 |
>= | Greater or equal | arrival_time>=06:00:00 |
< | Less than | date<20260101 |
<= | Less or equal | route_type<=4 |
LIKE | SQL-style pattern match | stop_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 patterns
Section titled “LIKE patterns”LIKE matches against a pattern where:
%stands for any sequence of characters (including empty)._stands for exactly one character.
| Pattern | Matches |
|---|---|
Gare% | Gare Centrale, Gare du Nord, Gare |
%Nord | Gare du Nord, Nord |
%bus% | Any value containing bus |
stop___ | stop001, stopABC — exactly 4+3 = 7 chars |
Whitespace
Section titled “Whitespace”Whitespace around operators is optional and does not change meaning:
stop_id=S01stop_id = S01stop_id = S01Backtick-quoted values
Section titled “Backtick-quoted values”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.
Combining expressions
Section titled “Combining expressions”AND and OR let you compose filters. AND takes higher precedence, so
a=1 AND b=2 OR c=3parses 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=3Examples
Section titled “Examples”Single-field filters
Section titled “Single-field filters”gapline read stops --where "stop_id=S01"gapline read routes --where "route_type!=3"Range on a numeric-looking field
Section titled “Range on a numeric-looking field”gapline read stop-times --where "stop_sequence>10 AND stop_sequence<20"Pattern match
Section titled “Pattern match”gapline read stops --where "stop_name LIKE Gare%"gapline read stops --where "stop_name LIKE %Nord"Combining with OR
Section titled “Combining with OR”gapline read routes --where "route_type=3 OR route_type=1"A value with a reserved keyword
Section titled “A value with a reserved keyword”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.
Errors
Section titled “Errors”Common parser errors and what they mean:
| Error | Cause |
|---|---|
invalid expression: '' | --where "". Pass an expression or drop the flag. |
unexpected logical operator without expressions | AND …, … 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. |
See also
Section titled “See also”gapline read—--whereis optional; omit to read every record.gapline updateandgapline delete—--whereis required.- Concepts / Referential integrity — what happens after the match set is computed.