Load list column from text
Split a text into sections and read each one against a pattern, collecting one record per section into a new list column – or refuse the whole text, naming the sections that do not fit.
Ingredient Family: rowActionsIngredients
Outline Display: Split {{text}} into sections and read each against the pattern {{pattern}}, adding list column {{newColumn}} with each section’s position in {{sequenceColumn}} and: {{columns}}A text with a section that does not fit is refused with: {{message}}
Details
This is where a list is built from text: a document whose paragraphs each carry a label, a block of Key: value lines, a comma-separated list. The text is split on separator (taken literally, not as a pattern), each piece is trimmed, and empty pieces are dropped. Carriage returns are removed first, so a document with Windows line endings splits on a blank line like any other.
Every section must then match pattern from its first character to its last. The step anchors the pattern itself, so a pattern need not (and an alternation cannot safely) anchor its own ends. columns says which capture groups become columns of the section’s record, all of them text; sequenceColumn adds the section’s position, counting from 1, so the records can be stored as rows and read back in order.
The step is fail-closed. One section that does not match, or whose captured text matches a column’s mustNotMatch, refuses the whole text: the new column is not produced, no later step runs, and the caller is told message followed by each offending section’s number, its opening words, and what is wrong with it. A caller that is a model reads that, fixes those sections, and sends the text again. So a rule such as “every paragraph starts with a marking” is enforced by the step rather than asked of the caller. What the step cannot know is whether a label that is present is the right one.
Mind what a section can hide. A pattern whose text group runs to the end of the section accepts a section that holds a second label further in, and files all of it under the first: give the text column a mustNotMatch naming the label pattern. And a section is whatever lies between two separators, so with a blank-line separator two paragraphs divided by a single line break are one section: exclude the line break from the text group to refuse such a section. [^\n]* in place of .* says so explicitly, although . does not match a line break either.
A text with no sections at all – empty, or nothing but separators and white space – is refused the same way. A column that names a group the pattern does not have fails the step as a malfunction on every call, whatever the text.
Local scope
The parent slot binds these (look up the slot in the parent to see how):
$table– The table to act on
Names introduced within this component’s knobs:
captureTable– empty table populated by ingredients
Settings
Required
-
text: formula (returns text; required, non-nullable)
A formula producing the text to split
Scope: all columns of$table(reference as[ColumnName], e.g.,[Name],[Price]) -
separator: constant value (type: text; required, non-nullable)
The literal text that divides one section from the next, such as a blank line or a comma -
pattern: constant value (type: text; required, non-nullable)
A regex (RE2 syntax) every section must match in full; its capture groups are whatcolumnsreads -
message: constant value (type: text; required, non-nullable)
What a section must look like, told to the caller when a text is refused; state the rule, e.g. “Every paragraph must begin with one of (U), (C), (S) or (TS).” -
sequenceColumn: new column (type: integer; required, non-nullable)
The name of the column holding each section’s position in the text, counting from 1 -
newColumn: new column (type: list ofcaptureTable’s full row type)
The name of the new list column to create
Optional
columns: ingredient slot oftextCaptureIngredients(captureTable)(many)
The columns of each section’s record, one per capture group read