Map Table Row

Verb: mapTableRow

Available from: <Standard>

Maps the contents of a row on a data table using a specific mapping.

Syntax

mapTableRow --dataTable(DataTable) --row(Numeric) --mappings(String)

Inputs

Script Designer Required AcceptedTypes Description
--dataTable Data Table Required Data Table Data table to be mapped.
--row Row Required Number Number indicating the line to be mapped.
--mappings Mappings Required Text Maps the contents of a specific row according to the value entered in the "Column Name", "Column Number", and "Column Value" parameters.
A value must be entered only in the "Column Name" or "Column Number" field. If values are entered in both fields, the command considers the value entered in "Column Name".

Example

Example 1: Command performs mapping of the contents of row "1" of a specific table, filtering as a parameter the columns "1" and "2" of the data table and returning the contents of row "1" from according to the data in these columns.

defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
defVar --name excelSecondRowFirstColumn --type String
defVar --name excelSecondRowSecondColumn --type String
//
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet  --entiretable  --hasheaders  excelTable=value
//
mapTableRow --dataTable ${excelTable} --row 2 --mappings "number=1=${excelSecondRowFirstColumn},number=2=${excelSecondRowSecondColumn}"
logMessage --message "First mapped content: ${excelSecondRowFirstColumn}\r\nSecond mapped content: ${excelSecondRowSecondColumn}\r\n" --type "Info"
// The example returns the following output:
// First mapped content: Microsoft Corporation
// Second mapped content: São Paulo

Example 2: Mapping of the contents of all rows of a specific data table. For this, the repetition loop For is used, filtering the columns "1" and "2", thus returning the contents of the row according to the data of these columns.

defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
defVar --name firstMappedColumn --type String
defVar --name secondMappedColumn --type String
defVar --name rowsQuantity --type Numeric
defVar --name counter --type Numeric --value 1
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable --hasheaders excelTable=value rowsQuantity=rows
// Using the "To" loop will be to map all rows contained in the data table.
for --variable ${counter} --from ${counter} --to ${rowsQuantity} --step 1
mapTableRow --dataTable ${excelTable} --row ${counter} --mappings "number=1=${firstMappedColumn},number=2=${secondMappedColumn}"
logMessage --message "Mapped line content: ${firstMappedColumn},${secondMappedColumn}\r\n" --type "Info"
next
// The example returns the following output:
// Mapped line content: // IBM Corporation, Toronto
// Mapped line content: Microsoft Corporation, São Paulo
// Mapped line content: // IBM Corporation, Armonk

Download File


For the correct operation of the scripts above, it is necessary to download the files and enter their path in the File parameter of the Open Excel File command.

See Also

  • Add Column
  • Add Row
  • Check for Column Existence in Table
  • Copy Rows
  • Copy Table
  • Delete Column
  • Delete Rows
  • Filter Table
  • Find Column by Name
  • Find Table Cell Occurrences
  • Get Cell Contents
  • Get Column Name
  • Get Column Structure
  • Get HTML Tables
  • JSON to Table
  • Move Table Rows
  • Sort Table
  • Update Row
  • Write Table to File