Shape · Text

Text Operations

Cleans text columns: change case, trim spaces, find and replace, pad, cut, add a prefix or suffix, or take the length. One node can clean several columns.

Also known as: Trim, upper case, cleanse

How it works

Click Add operation for each step and pick its type: Uppercase, Lowercase, Title Case (every word starts with a capital, as Excel's PROPER does), Trim, Trim left, Trim right (which also remove tabs, newlines and non-breaking spaces), Replace (find and replace with, plain or regex), Length, Pad (width, Left or Right, fill character defaulting to a space), Slice (0-based start and exclusive stop; a negative start counts from the end), Add prefix or Add suffix. Each operation runs on one column, a list of columns or every text column. In place overwrites the source; otherwise give an output column, where $1 stands for the source name, so $1_clean on city writes city_clean. Operations run in order and in-place ones chain, so a later step sees the earlier result. Nulls pass through unchanged.

Inputs and outputs

Inputs

  • data — Table

Outputs

  • data — Table

Settings

The Attributes panel of Text Operations, as in the app: the controls work, but nothing runs — there is no data behind it.

The same settings, as the Assistant writes them
{
  operations: [{ type: "upper"|"lower"|"title"|"strip"|"lstrip"|"rstrip"|"replace"|"len"|"pad"|"slice"|"prefix"|"suffix", column: string, columns?: string[], allTextColumns?: boolean, outputColumn?: string, from?: string, to?: string, regex?: boolean, width?: number, side?: "left"|"right", fillchar?: string, start?: number, stop?: number, value?: string } ]
}

strip/lstrip/rstrip trim whitespace; lower/upper/title change case; replace needs from+to — with regex true, from is an RE2 regex replacing every match (DuckDB regexp_replace), e.g. from "\s+" to " " collapses runs of whitespace; pad needs width+side; prefix/suffix need value. Use the LITERAL type names — "trim" or "lowercase" are not recognised. One op can cover several columns: list them in columns, or set allTextColumns to apply it to every text column of the input. Without outputColumn an op writes in place; "$1" in outputColumn is the source column name (e.g. "$1_clean"), and a multi-column op whose outputColumn has no "$1" writes <outputColumn>_1, _2, … in column order.

Example

Customer names arrive padded and in mixed case. Add Trim on name in place, then Title Case on name with output $1_clean: o'cahill becomes O'Cahill in name_clean.