unpack
Separate values contained in lists into columns in a data extract.
Introduction
Use the unpack enrichment to separate lists contained in a single column of a data extract into separate columns. This enrichment can also unpack a list of lists.
Before you unpack the lists, run the convertx enrichment with the following Python expression: __import__('ast').literal_eval({FIELD})
Replace FIELD
with the name of the column that contains the lists. Running this enrichment enables Adverity to read the lists. For more information, see the Python documentation.
Creating the enrichment
For more information on creating an enrichment, see Using custom scripts.
Configuring the enrichment
To configure the enrichment, fill in the following fields. Required fields are marked with an asterisk (*).
-
Field
-
Enter the name of the column that contains the lists.
-
Newfields
-
Enter the names of the new columns that are to be added to the data extract. Specify as many column names as the number of elements in the longest list.
-
Includeoriginal
-
Select this checkbox to keep the column that contains the lists in the data extract.
-
Missing
-
Enter a value with which Adverity populates empty columns. Use this option if the lists have different lengths.
Example
Enrichment configuration
-
Field*
-
Account IDs
-
Newfields
-
-
ID 1
-
ID 2
-
ID 3
-
ID 4
-
-
Includeoriginal
-
Select this checkbox.
-
Missing
-
null
Data table before enrichment
Campaign |
Account IDs |
---|---|
Brand |
[1, 2, 3, 4] |
Brand |
[5, 6, 7] |
Dashboard |
([A, B, C], [D, E, F]) |
Data table after enrichment
Campaign |
Account IDs |
ID 1 |
ID 2 |
ID 3 | ID 4 |
---|---|---|---|---|---|
Brand |
[1, 2, 3, 4] |
1 |
2 |
3 |
4 |
Brand |
[5, 6, 7] |
5 |
6 |
7 |
null |
Dashboard |
([A, B, C], [D, E, F]) |
[A, B, C] |
[D, E, F] |
null |
null |