Contents:
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.
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 select Rename... from the column drop-down.
- To rename multiple columns, you can select values in the Column Browser and perform batch renames. See Rename Columns.
- 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 Extractlist Transform.
- See Merge Transform.
- See Nest Transform.
Basic Usage
Rename a single column:
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: col: column_ref [prefix: 'strPrefix'] [suffix: 'strSuffix'] [mapping: [column1,'newColumn1Name'], [column2,'newColumn2Name']] [on: `patternOrLiteral`] [with: 'replacementString'] [sourceRowNumber: intRowNum]
Token | Required? | Data Type | Description |
---|---|---|---|
rename | Y | transform | Name of the transform |
col | Y | string | Name of column or columns to rename |
prefix | N | string | (batch column) Prefix to prepend to the column name |
suffix | N | string | (batch column) Suffix to append to the column name |
mapping | N | array | (batch column) Array containing mappings from old column name and new column name |
on | N | string | (batch column) Pattern or string literal for which to search each column name |
with | N | string | (batch column) Replacement value for found pattern or string literal in column names |
sourcerownumber | N | integer | (batch column) Row number from the source data to use as the new names for the selected columns |
For more information on syntax standards, see Language Documentation Syntax Notes.
col
Identifies the column or columns to which to apply the transform.
NOTE: For renames of one or more columns to explicit names, specify the source and target columns using the mapping
parameter instead.
Usage Notes:
Required? | Data Type |
---|---|
Yes | String (column name) |
prefix
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 |
suffix
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 |
mapping
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 |
on
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) |
with
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) |
sourcerownumber
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) |
Tip: For additional examples, see Common Tasks.
Examples
Rename a column
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 |
Transform:
Perhaps you know the units are centimeters. You can rename using the following:
rename mapping: [LengthX, 'LengthX_cm']
Now, you want to convert the units of measure to inches. You can use the derive
transform to convert values and generate a new column name:
derive type:single value: (LengthX_cm * 0.393701) as:'LengthX_in'
You might want to reformat the generated values using transforms like the following, which rounds the results to two decimal points:
set col:LengthX_in value:NUMFORMAT(LengthX_in, '##.00')
NOTE: The set
transform does not support the as
parameter.
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.
Rename multiple columns
Source:
column1 | column2 | column3 | column4 | column5 |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |
Transform:
Add prefix:
rename col: column1,column2,column3,column4,column5 prefix: 'new_'
new_column1 | new_column2 | new_column3 | new_column4 | new_column5 |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |
Add suffix:
rename col: new_column1,new_column2,new_column3,new_column4,new_column5 suffix: 'a'
new_column1a | new_column2a | new_column3a | new_column4a | new_column5a |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |
Find and replace:
rename col: new_column1,new_column2,new_column3,new_column4,new_column5 on:'_column' with: 'Field'
new_Field1a | new_Field2a | new_Field3a | new_Field4a | new_Field5a |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |
Manual rename:
rename mapping: [newField1a,'firstColumn'],[newField2a,'secondColumn']
firstColumn | secondColumn | new_Field3a | new_Field4a | new_Field5a |
---|---|---|---|---|
data1 | data2 | data3 | data4 | data5 |
Use row as header:
rename sourcerownumber: 2
data1 | data2 | data3 | data4 | data5 |
---|---|---|---|---|
data6 | data7 | data8 | data9 | data10 |
This page has no comments.