Unpack data values within Python lists.
As per the example below, in most cases it will be necessary to prepend a "convertx" transformation in order to make the Python list parsable.
Example
Example Input
dim_A | dim_B | list_1 |
AAA | DDD | [1, 2, 3, 4] |
BBB | EEE | ([1, 2, 3], [3, 2, 1]) |
CCC | FFF | ["one", "two", "three"] |
Example Output
dim_A | dim_B | new_field |
AAA | DDD | 1 |
AAA | DDD | 2 |
AAA | DDD | 3 |
AAA | DDD | 4 |
BBB | EEE | [1, 2, 3] |
BBB | EEE | [3, 2, 1] |
CCC | FFF | one |
CCC | FFF | two |
CCC | FFF | three |
I Ain't Afraid of No Code!
[
"convertx",
{
"subtable": null,
"field": "list_1",
"expression": "__import__('ast').literal_eval({list_1})",
"_comment": null
}
],
[
"unpacklist",
{
"include_original": false,
"subtable": null,
"field": "list_1",
"newfield": "new_field",
"_comment": null
}
]
param boolean include_original: Retain source field.
param str subtable: Name a subtable in which output will be stored (will create subtable where necessary).
param str field: Name of field containing a list.
param str newfield: Column field to be created to hold the unpacked list.
param str comment: A comment th, at will appear in the Transformation UI.
Comments
0 comments
Article is closed for comments.