convertx
Convert values in a selected column in a data extract using a Python expression.
This guide explains how to configure the convertx instruction. To learn about another instruction, go back to the Available custom script instructions overview.
Introduction
Use the convertx instruction to use a Python expression to convert values in a selected column.
The Create or Edit Columns standard transformation enables you to edit the values in your data extract in a few easy steps, instead of using a custom script. For more information, see Create or Edit Columns.
If you want to use the convertx custom script instruction to select rows containing numbers, the values used in the instruction must be in numeric format. If necessary, use the convertnumbers custom script instruction to convert string values to a numeric format. Add the convertnumbers instruction to the same custom script transformation before the convertx instruction.
Creating a custom script transformation using the convertx instruction
To create and configure a custom script using the convertx instruction, follow these steps:
-
In the Configuration step, select the convertx instruction.
-
To configure the custom script instruction, fill in the required fields below, as well as any optional fields you require:
-
Field (required)
-
Enter the name of the column containing the values to convert.
-
Python expression (required)
-
Enter a Python expression to convert the values in the column you have selected.
-
Fail on error
-
Select this field to stop the transformation instruction if an error occurs.
Example
Transformation configuration
This transformation converts every character in the Ad Group column to lower case.
-
Fields
-
Ad group
-
Python Expression
-
{Ad Group}.lower()
Data table before transformation
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
OnGoing |
75856 |
Outreach |
OnGoing |
38753 |
Organic Growth |
InActive |
99651 |
Data table after transformation
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
ongoing |
75856 |
Outreach |
ongoing |
38753 |
Organic Growth |
inactive |
99651 |