Get Column Name
Verb: getColumnName
Gets the name of a column in a data table from its index.
Syntax
getColumnName --dataTable(DataTable) --index(Numeric) (String)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--dataTable | Data Table | Required | Data Table | Data table to get column name. |
--index | Index | Required | Number | Index of the column from which the name is obtained.
The number must be between 1 and 2147483647. If it exceeds that range, the message "Value out of range" is returned. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Name | Text | Returns the name of the obtained column. |
Example
The Get Column Name command returns the name of the column that was obtained at index "2" of the data table.
defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
defVar --name columnName --type String
// Data table with values.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable --hasheaders excelTable=value
getColumnName --dataTable ${excelTable} --index 2 columnName=value
excelClose --file ${excelFile}
logMessage --message "Obtained column name: ${columnName}" --type "Info"
// The example has the following output:
// Obtained column name: City
For the correct operation of the script above, it is necessary to download the file and enter its path in the File parameter of the Open Excel File command.
Remarks
If the Data Table contains no explicitly defined header, by default columns will be given generic names such as "Column n" ("n" being the number of the column's position, e.g. Column 1)