Skip to main content

Header Transform

Nota

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.

Uses one row from the dataset sample as the header row for the table. Each value in this row becomes the name of the column in which it is located.

This transform might be automatically applied as one of the first steps of your recipe.

Nota

If source row number information is not available due to changes in the dataset, this transform may not be available.

Nota

Each column in any row that is part of a column header in a dataset with parameters should have a valid value that is consistent with corresponding values across all files in the dataset. If your files have missing or empty values in rows that are used as headers in your recipe, these rows may be treated as data rows during the import process, which may result in unexpected or missing column values. For more information, see Create Dataset with Parameters.

Basic Usage

header sourcerownumber: 4

Output: The values from Row #4 of the original dataset are used, if available, as the names for each column. If the row is not available, the specified row data can be retrieved, and the transform fails.

Syntax and Parameters

header sourcerownumber: row_num

Token

Required?

Data Type

Description

header

Y

transform

Name of the transform

sourcerownumber

Y

integer (positive)

Row number from the original data to use as the header.

For more information on syntax standards, see Language Documentation Syntax Notes.

sourcerownumber

The sourcerownumber parameter defines the row number to apply to the transform step.

This parameter references the original row number of the sample in the dataset.

  • sourceownumber parameter must be an integer that is less than or equal to the total number of rows in the original sample.

  • If the corresponding row has been deleted from the dataset, the transform step generates an error.

Example:

header sourcerownumber: 4

Output: Uses row #4 from the source row numbers of the sample as the header the columns.

Usage Notes:

Required?

Data Type

Yes

integer (positive)

Examples

Sugerencia

For additional examples, see Common Tasks.

Example - Header from row that is not the first one

This example illustrates how you can rename columns based on the contents of specified rows.

Source:

You have imported the following racer data on heat times from a CSV file. When loaded in the Transformer page, it looks like the following:

(rowId)

column2

column3

column4

column5

1

Racer

Heat 1

Heat 2

Heat 3

2

Racer X

37.22

38.22

37.61

3

Racer Y

41.33

DQ

38.04

4

Racer Z

39.27

39.04

38.85

In the above, the (rowId) column references the row numbers displayed in the data grid; it is not part of the dataset. This information is available when you hover over the black dot on the left side of the screen.

Transformation:

You have examined the best performance in each heat according to the sample. You then notice that the data contains headers, but you forget how it was originally sorted. The data now looks like the following:

(rowId)

column2

column3

column4

column5

1

Racer Y

41.33

DQ

38.04

2

Racer

Heat 1

Heat 2

Heat 3

3

Racer X

37.22

38.22

37.61

4

Racer Z

39.27

39.04

38.85

You can use the following transformation to use the third row as your header for each column:

Transformation Name

Rename column with row(s)

Parameter: Option

Use row(s) as column names

Parameter: Type

Use a single row to name columns

Parameter: Row number

3

Results:

After you have applied the above transformation, your data should look like the following:

(rowId)

Racer

Heat_1

Heat_2

Heat_3

3

Racer Y

41.33

DQ

38.04

2

Racer X

37.22

38.22

37.61

4

Racer Z

39.27

39.04

38.85