convertpacked
Convert the keys and values in a dictionary using a Python expression.
This guide explains how to configure the convertpacked instruction. To learn about another instruction, go back to the Available custom script instructions overview.
Introduction
Use the convertpacked instruction to convert the keys and values in a dictionary using a Python expression. Use {__value}
to access the values in a dictionary and {__key}
to access the keys. To unpack a dictionary into separate columns, use the unpackdict transformation.
Creating a custom script transformation using the convertpacked instruction
To create and configure a custom script using the convertpacked instruction, follow these steps:
-
In the Instructions step, select the convertpacked instruction.
-
To configure the custom script instruction, fill in the following fields. Required fields are marked with an asterisk (*).
-
Fieldname
-
Enter the name of the column containing the dictionaries to convert.
-
Python Expression
-
Enter the Python expression to convert the values or keys in a dictionary.
For example, enter
float({__value})
to convert the numerical values into a float. -
Format
-
Select the format of the dictionary to convert. Select either json or yaml.