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 enrichment 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 enrichment before the convertx instruction.

Creating a custom script enrichment using the convertx instruction

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

  1. Create a custom script enrichment.

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

  3. 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 enrichment instruction if an error occurs.

Example

Enrichment configuration

This enrichment converts every character in the Ad Group column to lower case.

Fields

Ad group

Python Expression

{Ad Group}.lower()

Data table before enrichment

Campaign

Ad Group

Clicks

Brand

OnGoing

75856

Outreach

OnGoing

38753

Organic Growth

InActive

99651

Data table after enrichment

Campaign

Ad Group

Clicks

Brand

ongoing

75856

Outreach

ongoing

38753

Organic Growth

inactive

99651