Get Column Structure

Gets the structure of all columns of a data table.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Gets the structure of all columns of a data table.

Limitations

If you get data tables from Excel spreadsheets, all columns will have the Text data type. Starting from version 23.0.16, this is no longer the case and the columns will match the data types from the Excel spreadsheet.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

getColumns --dataTable(DataTable) (List<String>)=names (DataTable)=schema

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Data Table dataTable Required Data Table Data table that is used to get the column data.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Names names List<Text> Returns a list of the column names that were obtained.
Schema schema Data Table Returns a data table with the column names and their data types.

Example

The command obtains the name of all columns of a data table and their structure, which are the column names and their data types.

defVar --name excelSheet --type Excel
defVar --name obtainedExcelTable --type DataTable
defVar --name columnsName --type List --innertype String
defVar --name dataTypeColumns --type DataTable
// Data table with values.
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelSheet=value
excelGetTable --file ${excelSheet} --getfirstsheet --entiretable --hasheaders obtainedExcelTable=value
//
getColumns --dataTable ${obtainedExcelTable} columnsName=names dataTypeColumns=schema
logMessage --message "Name of Column(s): ${columnsName}\r\nTable Structure: ${dataTypeColumns}" --type "Info"
// This example returns the output:
// Name of Column(s): [Company,City]
// Table Structure:
// Company, Text
// City, Text