Find Column by Name
Verb: findColumnByName
Available from: <Enterprise>
Finds the position of a column in a data table by searching for its name.
Syntax
findColumnByName --dataTable(DataTable) --name(String) (Numeric)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--dataTable | Data Table | Required | Data Table | Data table to find the columns. |
--name | Column Name | Required | Text | Text with the name of the column to perform the search.
This parameter is not case sensitive, so columns accept lower case or upper case letters for searching. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Column | Number | Returns the index number corresponding to the column position in the data table. |
Example
The Find Column by Name command finds the position of the "City" column within the specified data table and returns its index number.
defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
defVar --name columnIndex --type Numeric
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable --hasheaders excelTable=value
findColumnByName --dataTable ${excelTable} --name City columnIndex=value
logMessage --message "Column position found: ${columnIndex}" --type "Info"
excelClose --file ${excelFile}
// This example returns the following output:
// Column position found: 2
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.