Skip to content

Map and shape columns

Mapping turns the columns a source delivers into the columns your workflow works with: new names, clean values, exact types, and only the columns you need.

fromFile("../counterparties.csv")
setProp("LEI", trim(prop("lei_code")).upper())
setProp("Name", prop("legal_name"))
setProp("Limit", prop("credit_limit"))
setType("Limit", "number")
keepProps("LEI", "Name", "Limit")
rowKey("LEI")
Statement Effect
setProp(name, value) Writes a column on every row: a new name adds a column, an existing name replaces its value
setType(name, type) Converts a column to "number", "date", "text", or "boolean" from that statement on
keepProps(name, …) Keeps only those columns, in that order
unsetProp(name) Removes one column
rowKey(name, …) Names the columns that make a row the same row across runs
splitRows(list, name) Turns each item of a list into a row of its own
spreadProps(object) Writes one level of an object’s fields as columns of the row

setProp(name, value) writes the value on every row. To rename a column, write it under the new name and drop the old one:

setProp("Order ID", prop("id"))
unsetProp("id")

To compute a column, write any expression:

setProp("Net", prop("Gross") - prop("Fee"))
setProp("Trade month", formatDate(prop("trade_date"), "YYYY-MM"))
setProp("Counterparty", prop("cpty_name").trim())

A setProp inside if writes only on the rows where the condition holds. The other rows keep their value, or hold empty when the column is new:

if(prop("side") == "S", setProp("Quantity", -prop("Quantity")))

Statements read the row as earlier statements left it

Section titled “Statements read the row as earlier statements left it”

Each statement reads the row as the statements before it left it. When one setProp replaces a column with a value from somewhere else, a later statement that reads that column would get the new value, so the editor reports it as an error. Swapping two columns in two lines is the classic case:

setProp("a", prop("b"))
setProp("b", prop("a")) # error: "a" was replaced above

Write through a temporary column instead:

setProp("old_a", prop("a"))
setProp("a", prop("b"))
setProp("b", prop("old_a"))
unsetProp("old_a")

A setProp that reads its own column, such as setProp("Name", trim(prop("Name"))), is a transformation rather than a replacement, so later statements read the cleaned value without an error.

A dotted name such as "bond.isin" is one column. JSON output nests it as { "bond": { "isin": … } }; CSV keeps the dotted name as the header.

setType(name, type) converts a column’s values to "number", "date", "text", or "boolean", and the column has that type for every later statement. A value that cannot convert fails the run, naming the value, for example Cannot convert "30/09/2026" to date; text must be an ISO 8601 date. Empty stays empty.

Type Converts
"number" Text is parsed as a number; a boolean is 1 or 0; a date is its Unix timestamp in milliseconds
"text" Numbers in plain notation; dates as ISO-8601 UTC
"date" Text in ISO-8601 form; a blank text is empty
"boolean" The texts true and false; a blank text is empty
setType("amount", "number")
setType("trade_date", "date")

For dates in another format, parse them with a pattern instead: setProp("trade_date", parseDate(prop("trade_date_text"), "DD/MM/YYYY")). See Transform values.

Use setType after a source that delivers text, such as a CSV, a subgrid, a query, or a script, so the statements after it can do arithmetic and date maths.

keepProps(name, …) keeps only the named columns, in that order, and removes every other one. Later statements can read only those names, and naming a column the row does not have is a type error.

keepProps("Order ID", "Customer", "Net")

unsetProp(name) removes one column and keeps the rest.

rowKey(name, …) declares the columns that identify a row across runs, such as a trade id or the pair of an account and a date:

rowKey("trade_id")
rowKey("account", "value_date")

Exception management matches the exceptions of a later run to the same row by this key.

Some sources deliver a list inside one cell: a JSON envelope such as { "date": …, "rows": [ … ] }, the tables of a PDF, or the repeating tags of a SWIFT message. splitRows(list, name) makes one row per item, with the item under name and every other column copied:

fromFile("../positions-envelope.json")
splitRows(prop("rows"), "item")
setProp("ISIN", prop("item").prop("isin"))
setProp("Quantity", prop("item").prop("qty"))
setProp("As of", prop("date"))
unsetProp("item")
unsetProp("rows")
  • An object item is carried whole, so .prop reads its fields afterwards, one setProp per field.
  • An empty list drops the row.
  • Lists inside lists split once per level.
  • A PDF table splits over its grid: splitRows over the table’s data.grid gives one row per table row, and prop("cells").at(0).prop("text") reads a cell. See Supported formats.

splitRows is a row-set statement like groupBy, so it stands on its own line and never inside if or do.

An API answer or a JSON file often holds a nested object in one cell. spreadProps(object) writes that object’s fields as columns, named by their keys. It spreads one level. A field that is itself an object becomes a column holding that object.

spreadProps(prop("price"))

On a row {"id": "p1", "price": {"value": 101.2, "ccy": "EUR"}}, that statement adds value and ccy and removes price, because the argument is a plain column read. Any other expression leaves the existing columns in place.

Chain .prefix(text) and .value(expression) in either order:

spreadProps(prop("price")).prefix("p.")
spreadProps(prop("properties")).value(ifs(current.prop("type") == "number", current.prop("number"), current))

.prefix("p.") joins that text onto each name (p.value, p.ccy). .value(expression) runs once per field with current bound to that field’s value, and the result is the cell.

A collision with a column the row already has fails the run. Empty (missing or null) adds no columns. Text, a number, a boolean, a date, or a list fails, naming the row. spreadProps is a row-set statement like groupBy: it stands on its own line, never inside if, do, or each.

To check every item of a list without making rows of them, use each; see Validate data.

A cell can hold a JSON object. Read its fields with .prop, as deep as the object goes:

setProp("Issuer country", prop("bond").prop("issuer").prop("country"))

A cell holds text, a number, a boolean, a date, or a list of those, so you map an object’s fields into columns rather than writing the object itself. A cell no statement writes keeps its JSON exactly as it arrived. See Language basics.