unpack

Separate values contained in lists into columns in a data extract.

This guide explains how to configure the unpack instruction. To learn about another instruction, go back to the Available custom script instructions overview.

Introduction

Use the unpack instruction to separate lists contained in a single column of a data extract into separate columns. This transformation can also unpack a list of lists.

Before you unpack the lists, run the convertx transformation with the following Python expression: __import__('ast').literal_eval({FIELD})

Replace FIELD with the name of the column that contains the lists. Running this transformation enables Adverity to read the lists. For more information, see the Python documentation.

Creating a custom script transformation using the unpack instruction

To create and configure a custom script using the unpack instruction, follow these steps:

  1. Create a custom script transformation.

  2. In the Instructions step, select the unpack instruction.

  3. To configure the custom script instruction, 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

Transformation configuration

Field*

Account IDs

Newfields

  • ID 1

  • ID 2

  • ID 3

  • ID 4

Includeoriginal

Select this checkbox.

Missing

null

Data table before transformation

Campaign

Account IDs

Brand

[1, 2, 3, 4]

Brand

[5, 6, 7]

Dashboard

([A, B, C], [D, E, F])

Data table after transformation

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