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 current Transform node and Python scripting. The data flow containing the original Expand From List node [based on the superseded version of the Transform node] is retained on this article for continuity. However Infogix recommends the use of the new 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:
|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:
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.
|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|
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. ::
- You will need version 3.1.5 or later to import the .lna file containing the updated node.