Rename Transform
Note
Transforms are a part of the underlying language, which is not directly accessible to users. This content is maintained for reference purposes only. For more information on the user-accessible equivalent to transforms, see Transformation Reference.
Renames one or more columns based on specified names, patterns, row values, or prefixes and suffixes. You can also rename to uppercase or lowercase values.
Note
Column names are case-insensitive and cannot begin with whitespace.
Tip
To prevent potential issues with downstream systems, you should limit your column lengths to no more than 128 characters.
Other ways to rename:
It's easier to rename columns through the user interface.
To rename a single column, double-click the column name or selectRename...from the column drop-down in the Transformer Page.
To rename multiple columns, you can select values in the Column Browser and perform batch renames.
Transforms that generate new columns might support the
as
parameter, which enables specifying the name of the new column. Using theas
parameter avoids the extra step of adding arename
transform after column generation.See Derive Transform.
See Extractkv Transform.
See Merge Transform.
See Nest Transform.
Basic Usage
Rename a single column manually:
rename mapping: [oldName,'NewName']
Output: Renames the column OldName
to NewName
.
Rename multiple columns:
This transform supports multiple methods for renaming two or more columns in a single step. See below for examples.
Syntax and Parameters
rename: type: renameType col: column_ref [mapping: [column1,'newColumn1Name'], [column2,'newColumn2Name']] [prefix: 'strPrefix'][suffix: 'strSuffix'] [keepIndex: NumOfChars][on: `patternOrLiteral`] [with: 'replacementString'] [method: strMethodType] [sourcerownumber: intRowNum] [sourcerownumbers: strCommaList]
Token | Required? | Data Type | Description |
---|---|---|---|
rename | Y | transform | Name of the transform |
type | Y | string | Enum of supported renaming types. For more information, see "type" below. |
col | Y | string | Name of column or columns to rename |
prefix | N | string | (type=prefix) Prefix to prepend to the column name |
suffix | N | string | (type=suffix) Suffix to append to the column name |
keepIndex | N | integer | (type=keepLeft or type=keepRight) Number of characters on the left or right side of the column to retain |
mapping | N | array | (type=manual) Array containing mappings from old column name and new column name |
on | N | string | (type=findAndReplace) Pattern or string literal for which to search each column name |
with | N | string | (type=findAndReplace) Replacement value for found pattern or string literal in column names |
method | N | string | (type=header) Enum of supported methods for renaming headers based on row numbers. See "method" below. |
sourcerownumber | N | integer | (type=header,method=index) Row number from the source data to use as the new names for the selected columns |
sourcerownumbers | N | string | (type=header,method=multi) Comma-separated list of row numbers from the source data to use as the new names for the selected columns |
separator | N | string | (type=header,method=multi) String to separate row values when multiple rows are used to define column headers. |
filltype | N | boolean | (type=header,method=multi) When |
sanitize | N | boolean | When |
For more information on syntax standards, see Language Documentation Syntax Notes.
Type of column rename to perform. Options:
Type | Description | Other required parameters |
---|---|---|
manual | Manual rename of one or more columns. |
|
prefix | Rename column by adding a prefix to it. |
|
suffix | Rename column by adding a suffix to it. |
|
findAndReplace | Rename the column using find and replace. |
|
keepLeft | Keep the leftmost characters in the column name |
|
keepRight | Keep the right characters in the column name |
|
upper | Rename column to use all uppercase characters. | None. |
lower | Rename column to use all lowercase characters. | None. |
header | Rename column based on a row number |
Additional parameters are required depending on the |
Usage Notes:
Required? | Data Type |
---|---|
Yes | Enum of supported String values. |
Identifies the column or columns to which to apply the transform.
Tip
The col
parameter must be specified for all types. You can use the *
wildcard to apply to all columns.
Usage Notes:
Required? | Data Type |
---|---|
Yes | Comma-separated list of column names (String values) |
An array describing the old names and new names for each column to rename.
Example:
Old column name | New column name |
---|---|
column1 | FirstName |
column2 | LastName |
column3 | Phone |
Transform step:
rename mapping: [column1,'FirstName'],[column2,'LastName'],[column3,'Phone']
Usage Notes:
Required? | Data Type |
---|---|
No | Array |
For batch rename using prefixes, this parameter specifies the string value with which to precede each of the column names.
Usage Notes:
Required? | Data Type |
---|---|
No | String |
For batch rename using suffixes, this parameter specifies the string value with which to append each of the column names.
Usage Notes:
Required? | Data Type |
---|---|
No | String |
For batch rename using find and replace, this parameter specifies the pattern or string literal to use to match values.
Replacement values are specified with the with
parameter.
Usage Notes:
Required? | Data Type |
---|---|
No | String (pattern or literal) |
For batch rename using find and replace, this parameter specifies the literal string values with which to replace the found pattern.
Find patterns and values are specified with the on
parameter.
Usage Notes:
Required? | Data Type |
---|---|
No | String (pattern or literal) |
For batch rename using keep-left or keep-right, this parameter specifies the number of characters on the left or right side of the column name to retain as the new column name.
Note
This value must be an integer greater than 0. If this value results in multiple columns having the same new name, you must specify a greater value to create unique names or use a different rename method.
Usage Notes:
Required? | Data Type |
---|---|
No | Integer |
Type of row-based column rename to perform. Options:
Type | Description | Other required parameters |
---|---|---|
index | Rename based on a single row number. |
|
filter | Use the values in the first row in the current sample to use as the new column names. | None. |
multi | Rename column by adding a suffix to it. |
Other parameters are applicable. See below. |
Usage Notes:
Required? | Data Type |
---|---|
No | Enum of supported row-based rename types (String). |
The row number from the original source data which contains the values to use to rename all columns in the dataset. The row is removed from its original position.
Note
If source row number information is no longer available, this method cannot be used for column rename.
Usage Notes:
Required? | Data Type |
---|---|
No | Integer (Positive value) |
A comma-separated list of the row numbers from the original source data containing the values to use to rename all columns in the dataset. These rows are removed from its original position.
Note
If source row number information is no longer available, this method cannot be used for column rename.
Usage Notes:
Required? | Data Type |
---|---|
No | Comma-separated list of row numbers (String) |
String value to separate row value entries in the column header when multiple rows are used to rename columns. This value is not required.
Usage Notes:
Required? | Data Type |
---|---|
No | String |
When set to true
, empty values encountered in row values used to rename the column header are replaced using the nearest non-empty column value to the left. Default is false
.
Usage Notes:
Required? | Data Type |
---|---|
No | Boolean |
When set to true
, new column headers are sanitized to remove special characters. Default is false
.
Usage Notes:
Required? | Data Type |
---|---|
No | Boolean |
Examples
Tip
For additional examples, see Common Tasks.
In the following dataset, the length columns do not include any units of measure.
Tip
For downstream consumption, any column that contains a measure should include the units of measure in the column name. Avoid including units of measure in cell values, which forces the column to be retyped as String type.
Source:
Object | LengthX | LengthY | LengthZ |
---|---|---|---|
ObjA | 10 | 20 | 30 |
ObjB | 3 | 4 | 5 |
ObjC | 6 | 9 | 12 |
Transformation:
Perhaps you know the units are centimeters. You can rename using the following:
Transformation Name |
|
---|---|
Parameter: Option | Manual rename |
Parameter: Column | LengthX |
Parameter: New column name | 'LengthX_cm' |
Now, you want to convert the units of measure to inches. You can use the New Formula transformation to convert values and generate a new column name:
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | (LengthX_cm * 0.393701) |
Parameter: New column name | 'LengthX_in' |
You might want to reformat the generated values using transformations like the following, which rounds the results to two decimal points:
Transformation Name |
|
---|---|
Parameter: Columns | LengthX_in |
Parameter: Formula | numformat(LengthX_in, '##.00') |
Repeat the above steps for the other length columns.
Results:
Object | LengthX_cm | LengthY_cm | LengthZ_cm | LengthX_in | LengthY_in | LengthZ_in |
---|---|---|---|---|---|---|
ObjA | 10 | 20 | 30 | 3.94 | 7.87 | 11.81 |
ObjB | 3 | 4 | 5 | 1.18 | 1.57 | 1.97 |
ObjC | 6 | 9 | 12 | 2.36 | 3.54 | 4.72 |
You can delete the original columns if needed.
Source:
column1 | column2 | column3 | column4 | column5 |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |
Transformation:
Add prefix:
Transformation Name |
|
---|---|
Parameter: Option | Add prefix |
Parameter: Columns | column1,column2,column3,column4,column5 |
Parameter: Prefix | 'new_' |
new_column1 | new_column2 | new_column3 | new_column4 | new_column5 |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |
Add suffix:
Transformation Name |
|
---|---|
Parameter: Option | Add suffix |
Parameter: Columns | new_column1,new_column2,new_column3,new_column4,new_column5 |
Parameter: Suffix | 'a' |
new_column1a | new_column2a | new_column3a | new_column4a | new_column5a |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |
Convert to UPPERCASE:
Transformation Name |
|
---|---|
Parameter: Option | Convert to UPPERCASE |
Parameter: Columns | Column1,Column2,Column3,Column4,Column5 |
COLUMN1 | COLUMN2 | COLUMN3 | COLUMN4 | COLUMN5 |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |
Find and replace:
Transformation Name |
|
---|---|
Parameter: Option | Find and replace |
Parameter: Columns | new_column1,new_column2,new_column3,new_column4,new_column5 |
Parameter: Find | '_column' |
Parameter: Replace | '_field' |
new_field1 | new_field2 | new_field3 | new_field4 | new_field5 |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |