unpacklist

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

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

Introduction

Use the unpacklist instruction to separate lists contained in a single column of a data extract into separate rows within a newly created column. 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 unpacklist instruction

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

  1. Create a custom script transformation.

  2. In the Instructions step, select the unpacklist 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.

Newfield

Enter the name of the new column that is to be added to the data extract. Adverity populates this column with the list items.

Include Original

Select this checkbox to keep the column that contains the lists in the data extract.

Subtable

Enter the name for a subtable that you want to use within this custom script.

A subtable is a temporary table that only exists for this custom script. You can apply additional instructions within the same custom script to the subtable. However, the subtable cannot be used in any other custom scripts.

If a subtable does not exist for the current custom script, the transformation is applied to the data extract, and the enriched data is output into the subtable. If the subtable already exists for the custom script, the subtable is used as the input for the transformation and optionally as the output.

Example

Transformation configuration

Field*

Account IDs

Newfield

IDs

Include Original

Leave this checkbox unselected.

Data table before transformation

Campaign

Account IDs

Brand

[1, 2, 3, 4]

Brand

["Five", "Six", "Seven"]

Dashboard

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

Data table after transformation

Campaign

IDs

Brand

1

Brand

2

Brand

3

Brand

4

Brand

Five

Brand

Six

Brand

Seven

Dashboard

[A, B, C]

Dashboard

[D, E, F]