Update: This article has been updated with a data flow that includes a new version of the Expand From List node that is based on the Transform node and uses Python scripting. The data flow containing the original Expand From List node based on the Transform (Superseded) node is retained on this article for continuity. However, we recommend the use of the Transform node for new projects.
Let's say you have a list of values in a single field that are separated by a delimiter. Each of these rows should be expanded from the list in the field to a single row for each value in the list. The attached LNA provides some code to perform this "Expand from List" feature.
Let's say you have the following input data:
Account | State List |
11111111 | FL, MA, NE |
22222222 | CA, AZ, NV, NM |
In the attached LNA, you'll find a node named "Expand from List" that has the following properties set:
Property | Value |
ListExpr | 'State List' |
Delimiter | "," |
ItemField | State |
TrimItem | (blank) |
If you run this node--it's already configured in the LNA with the above values--it will output each value in the 'State List' field in its own record. The individual values will go into the 'State' field. The input values will be to the left of the 'State' field.
Account | State List | State |
11111111 | FL, MA, NE | FL |
11111111 | FL, MA, NE | MA |
11111111 | FL, MA, NE | NE |
22222222 | CA, AZ, NV, NM | CA |
22222222 | CA, AZ, NV, NM | AZ |
22222222 | CA, AZ, NV, NM | NV |
22222222 | CA, AZ, NV, NM | NM |
Happy Analyzing!
Additional comments on the updated node:
- The updated node is not intended as a direct replacement for the original node due to the differences in the Python language and BRAINScript.
- The name of the node property that specifies the input field containing the list has been changed from 'ListExp' to 'ListField'.
- Quote characters are no longer required around the text in the 'Delimiter' property.
- The node improves support for multi-character delimiters e.g. ::
Comments
0 comments
Please sign in to leave a comment.