Filter List
Uncontrolled node
Overview
Keep list items that pass a Python condition.
Keep the items that satisfy a condition, preserving their original values and order. The pattern is a Python expression evaluated for each item, not a text-search pattern.
This node is evaluated when another node needs its output. It has no run or done event.
Inputs
| Input | Type | Description |
|---|---|---|
| list | List | The list to filter. |
| Dynamic | Data | Simple variable names used in the pattern, such as minimum, can create extra input sockets. Connect the values needed by your expression. |
Properties
| Setting | Type | Description |
|---|---|---|
| pattern | Code | Python expression that returns True to keep an item or False to discard it. If unset or empty, removes false-like values instead. |
Outputs
| Output | Type | Description |
|---|---|---|
| output | Data | List of items that pass the condition. Empty lists and non-list inputs are returned unchanged. A pattern error can stop the workflow. |
Writing a condition
Use value for the current item and index for its zero-based position. For object fields, use Python dictionary notation such as value["score"].
For a numeric list [5, 12, 20], enter this pattern:
value > 10
The result is [12, 20].
To use a configurable limit, enter value > minimum and connect a Number node to the resulting minimum socket. Confirm that the required extra sockets appear before using more complex patterns.
To keep records by score:
value["score"] > minimum
For [{"name": "Alex", "score": 7}, {"name": "Sam", "score": 9}] and minimum: 8, the result is [{"name": "Sam", "score": 9}].
Without a pattern
An empty pattern removes values such as false, 0, null and empty text. For example, [0, 1, false, "", null, "ready"] becomes [1, "ready"]. Empty objects and empty lists are retained. Supply an explicit condition when zero is meaningful data.
Use a Boolean expression rather than printing a result. Make sure every item has the fields used by the condition; a missing field or invalid expression can stop the run.