setheader
Rename the columns in your data extract.
This guide explains how to configure the setheader instruction. To learn about another instruction, go back to the Available custom script instructions overview.
Introduction
Use the setheader instruction to change the names of the columns in a data extract. You must provide a name for each column in the data extract, even if you do not wish to rename the column. Any column that does not have a name provided is removed from the data extract. See the example below.
Creating a custom script transformation using the setheader instruction
To create and configure a custom script using the setheader instruction, follow these steps:
-
In the Instructions step, select the setheader instruction.
-
To configure the custom script instruction, fill in the following fields. Required fields are marked with an asterisk (*).
-
Header*
-
Click and enter the new names for the columns. Enter the names in the order in which they are to be applied to the columns. If you do not want to change the name of a column, enter its current name. To make sure no columns are removed, enter a name for each column 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
In this example, we want to change the name of the first two columns in our data extract, and leave the third column the same. To do this, we need to enter names for all three columns - we simply enter the current name of the third column so that it is not deleted from the data extract.
-
Field*
-
Campaign Name
-
Advert Type
-
Clicks
Data table before transformation
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
media |
7 |
Branding |
ecommerce |
3 |
Dashboard |
brand awareness |
18 |
Brand |
Ecommerce |
4 |
Dashboard |
media|social |
5 |
Branding |
media |
11 |
Data table after transformation
Campaign Name |
Advert Type |
Clicks |
---|---|---|
Brand |
media |
7 |
Branding |
ecommerce |
3 |
Dashboard |
brand awareness |
18 |
Brand |
Ecommerce |
4 |
Dashboard |
media|social |
5 |
Branding |
media |
11 |