for_list
Loop the list of list or dict and create a new list to output.
Description
Loop the list of list or dict and create a new list to output.
Parameters
Parameter |
Type |
Required |
Default |
Comment |
---|---|---|---|---|
expression | expression |
Yes |
- |
Expression of a item for a created list. Item in the loop of list can be referred as item*. Item in the loop of dict can be referred as item*_val and item*_key. For the first loop item can be referred as item0. For the second loop item can be referred as item1. |
filter | expression |
No |
None |
Condition not to add item for a crated list. Loop item can be refereed as same as in expression. |
lists | list[list|dict] |
Yes |
- |
List of list or dict to make a nested loop. Single list or dict can be passed. |
out_bb | bool |
No |
False |
|
out_field | str |
No |
None |
Examples
# Create a list from list of list with filter parameter.
# Output: {'for_list': [3, 4, 6]}
- for_list:
name: "for_list"
lists: [[1, 2], [3, 4]]
expression: "item0*item1"
filter: "item0*item1>7"
# Create a list from list of list and dict.
# Output: {'for_list': ['head1:val1', 'head1:val2', 'head2:val1', 'head2:val2']}
- for_list:
name: "for_list"
lists: [["head1", "head2"], {"name1": "val1", "name2": "val2"}]
expression: "item0 + ':' + item1_val"
# Create a list from a single list.
# Output: {'for_list': [2, 4, 6]}
- for_list:
name: "for_list"
lists: [1, 2, 3, 4]
expression: "item0*2"
filter: "item0*2>7"
# Create a list from a dict.
# Output: {'for_list': ["key1-1", "key2-2"]}
- for_list:
name: "for_list"
lists: {"key1": 1, "key2": 2}
expression: "item0_key + '-' + item0_val | str"
# Create a list from nested lists of a dict.
# Output: {'for_list': ["hello, world", "foobar"]}
- for_list:
name: "for_list"
lists: [[{"first": "hello, ", "second": "world"}, {"first": "foo", "second": "bar"}]]
expression: "item0.first + item0.second"