Move Table Rows

Verb: moveRows

Available from: <Standard>

Moves rows from one table to another, filtering the row number or content that should be moved.

Syntax

moveRows --target(DataTable) [--orderby(String)] [--indexes(List<Numeric>)] [--where(String)] --dataTable(DataTable) (Boolean)=success (Numeric)=changedrowscount

Inputs

Script Designer Required AcceptedTypes Description
--target Target Table Required Data Table Data table that should receive the new rows.
--orderby Order By Optional Text Text corresponding to the type of sort used. The sort syntax is the column name and the acronyms "ASC" or "DESC", for ascending or descending, respectively.
You can enter more than one sort for different columns of the table. Such as: Company ASC, City DESC.
--indexes Indexes Optional List<Number>, List<Text>, Number Number referring to the index of the line that should be moved.
The number be between 1 and 2147483647. If this range is exceeded, the message "Value out of range" is returned.
--where Where Optional Text Text responsible for filtering and finding, given the column name, the value of the row cell to be moved.
1. The syntax used is based on "LINQ C #" query language standards. To filter by specific column data, for example, you can use the following option:
Company = 'IBM'.
All rows with this value will be moved.
2. The comparison operators used in this parameter are: >, <,> =, <=, <>, OR, AND, LIKE>%, IN, LIKE *, and NOT.
--dataTable Data Table Required Data Table Data table from which rows should be moved.

Outputs

Script Designer AcceptedTypes Description
success Success Boolean Returns "True" if the row is successfully moved, or "False" if otherwise.
changedrowscount Moved Rows Number Returns the number of number of rows that have been moved.

Example

Example 1: Rows containing the company name "IBM" are moved to a new data table. The new table with the rows that were moved, the number of rows that were moved, and the operation performed as "True" are returned.

defVar --name sourceExcelFile --type Excel
defVar --name sourceExcelTable --type DataTable
defVar --name excelDestinationTable --type DataTable
defVar --name successInMovingRows --type Boolean
defVar --name movedRowsNumber --type Numeric
defVar --name destinationExcelFile --type Excel
// Data table with values.
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" sourceExcelFile=value
excelGetTable --file ${sourceExcelFile} --getfirstsheet  --entiretable  --hasheaders  sourceExcelTable=value
// Data table without values.
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyEmptyCity.xlsx" destinationExcelFile=value
excelGetTable --file ${destinationExcelFile} --getfirstsheet  --entiretable  --hasheaders  DestinationExcelTable=value
//
moveRows --target ${DestinationExcelTable} --orderby "Company ASC" --where "Company = \'IBM\'" --dataTable ${sourceExcelTable} movedRowsNumber=changedrowscount successInMovingRows=success
logMessage --message "Source table after moving row: ${sourceExcelTable}\r\nNew table: ${DestinationExcelTable}\r\nMoved rows number: ${movedRowsNumber}\r\nSuccess: ${successInMovingRows}" --type "Info"
// This example returns the following output:
// Source table after moving row: Microsoft Corporation, São Paulo
//
// New table: IBM Corporation, Toronto
// IBM Corporation, Armonk
//
// Moved rows number: 2
// Success: True

Example 2: The row for index "3" is moved to a new data table, returning the new table with the row that was moved and the number of rows moved, in this case only one row. There is also the return of performing the operation as "True".

defVar --name sourceExcelFile --type Excel
defVar --name sourceExcelTable --type DataTable
defVar --name excelDestinationTable --type DataTable
defVar --name successInMovingRows --type Boolean
defVar --name movedRowsNumber --type Numeric
defVar --name destinationExcelFile --type Excel
// Data table with values.
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" sourceExcelFile=value
excelGetTable --file ${sourceExcelFile} --getfirstsheet  --entiretable  --hasheaders  sourceExcelTable=value
// Data table without values.
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyEmptyCity.xlsx" destinationExcelFile=value
excelGetTable --file ${destinationExcelFile} --getfirstsheet  --entiretable  --hasheaders  excelDestinationTable=value
//
moveRows --target ${excelDestinationTable} --indexes 3 --dataTable ${sourceExcelTable} successInMovingRows=success movedRowsNumber=changedrowscount
logMessage --message "Source table after moving row: ${sourceExcelTable}\r\nNew Table: ${excelDestinationTable}\r\nMoved rows number: ${movedRowsNumber}\r\nSuccess: ${successInMovingRows}" --type "Info"
// This example returns the following output:
// Source table after moving row: IBM Corporation, Toronto
// Microsoft Corporation, São Paulo
//
// New Table: IBM Corporation, Armonk
//
// Moved rows number: 1
// Success: True

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.

Remarks

To execute the command, you must enter a value only in the parameter Indexes or the Where parameter, and there can be no values in both fields simultaneously.

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
  • Map Table Row
  • Sort Table
  • Update Row
  • Write Table to File