|
Dataset - Move column |
Declaration
<AMDATASET ACTIVITY="move_column" DATASET="text" COLUMNBY="text (options)" COLUMN="text/number" MOVETO="text (options)" DESTCOLUMN="text/number" />
Description
Moves a column anywhere in a dataset.
Practical Usage
Used to move a column anywhere in a dataset.
Parameters
General
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Dataset name | Text | Yes | (Empty) | DATASET="Customers" | Specifies the dataset to move the column in. |
Select by | Text (options) | Yes | Column name |
|
Specifies how to identify the column to move. The options are:
|
Column name | Text | Yes, if Select by is set to Column name | (Empty) | COLUMN="State" | The name of the column to move. This parameter is required if Select by is set to Column name. |
Column index | Number | Yes, if Select by is set to Column index | (Empty) | COLUMN="5" | The index number of the column to move. This parameter is required if Select by is set to Column index. |
Move to | Text (options) | Yes | End | MOVETO="index" MOVETO="end" MOVETO="before" MOVETO="after" |
Specifies where to move the column to. The options are:
|
Column index | Number | Yes, if Move to is set to Column index | (Empty) | DESTCOLUMN="7" | The column index number to move the column to. This parameter is required if Move to is set to Column index. |
Column name | Text | Yes, if Move to is set to Before specified column name or After specified column name | (Empty) | DESTCOLUMN="Zip" | The name of the column to move the column before or after. This parameter is required if Move to is set to Column name. |
Examples
- The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
- Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.
Example 1
This task uses the Create and Insert row Dataset activities to create a dataset with three columns and three rows and then moves the heading1 column to the end of the dataset.
<AMDATASET RESULTDATASET="myDataset" COLUMNS="heading1;heading2;heading3" DELIMITER="semi_colon" DESCRIPTION="This is user input description showing in variables panel of Task Builder" />
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row1" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row2" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row3" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="move_column" DATASET="myDataset" COLUMNBY="name" COLUMN="heading1" MOVETO="end" />
Example 2
This task uses the Create and Insert row Dataset activities to create a dataset with three columns and three rows and then moves the first column to appear after the heading3 column.
<AMDATASET RESULTDATASET="myDataset" COLUMNS="heading1;heading2;heading3" DELIMITER="semi_colon" DESCRIPTION="This is user input description showing in variables panel of Task Builder" />
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row1" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row2" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="insert_row" DATASET="myDataset" ROWLOCATION="end"><COLUMNSETTER COLUMNNAME="heading1" VALUE="Row3" /><COLUMNSETTER COLUMNNAME="heading2" VALUE="value2" /><COLUMNSETTER COLUMNNAME="heading3" VALUE="value3" /></AMDATASET>
<AMDATASET ACTIVITY="move_column" DATASET="myDataset" COLUMNBY="index" COLUMN="1" MOVETO="after" DESTCOLUMN="heading3" />