Built-in functions
Any extraction expression may append a pipeline of functions, separated by | and
applied left to right after the value is extracted, so [Grid | transpose | records]
transposes the range and then builds objects from it.
A specification cannot run arbitrary code. Functions are looked up in a fixed, built-in registry rather than evaluated. A specification can only invoke the functions listed here, plus any you supply yourself when calling
read_spec; it can never execute code of its own.
A function may take arguments after its name, separated by spaces. An argument is a
number (2), a double-quoted string (", "), or a bare word, which is read
as another range reference. The extracted value is always passed first, so
[Price | round 2] means round(Price, 2).
The list below is generated from the registry itself, so it cannot describe a function that does not exist.
Reshape
| Function | Typical input | Result |
|---|---|---|
records |
[table] |
first row is headings; remaining rows become a list of objects |
columns |
[table] |
first row is headings; columns become a {heading: [values]} object |
transpose |
[table] |
swaps rows and columns |
flatten |
[table] |
flattens nested rows into a single list |
Object
| Function | Typical input | Result |
|---|---|---|
keys |
{object} |
the object's keys |
values |
{object} |
the object's values |
items |
{object} |
the object as [key, value] pairs |
invert |
{object} |
swaps keys and values |
Coercion / formatting
| Function | Typical input | Result |
|---|---|---|
int |
any |
coerces every value to a whole number |
float |
any |
coerces every value to a floating-point number |
str |
any |
coerces every value to text |
round |
any |
rounds floating-point values; takes the number of places (default 2) |
isodate |
any |
formats date and time values as ISO-8601 strings |
