Delete Rows

Verb: deleteRows

Available from: <Standard>

Deletes one or more rows from a data table according to its index or a specific condition.

Syntax

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

Inputs

Script Designer Required AcceptedTypes Description
--indexes Indexes Optional List<Number>, List<Text>, Number Index of the row that should be deleted.
More than one line can be deleted.
--where Where Optional Text Text responsible for filtering the rows of the data table that should be deleted.
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 Robotic Process Automation'.
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 deleted.

Outputs

Script Designer AcceptedTypes Description
success Success Boolean Returns "True" if the data table row was deleted, or "False" otherwise.
changedrowscount Deleted Rows Number Returns the number of rows that were deleted.

Example

Example 1: Command deletes the row that is at index "1", returning "True" to indicate operation success and the number of rows deleted.

defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
defVar --name deletingResult --type Boolean
defVar --name deletedRowsQuantity --type Numeric
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCityDelete.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet  --entiretable  --hasheaders  excelTable=value
//
deleteRows --indexes 1 --dataTable ${excelTable} deletedRowsQuantity=changedrowscount deletingResult=success
logMessage --message "Deleted Rows Quantity: ${deletedRowsQuantity}\r\nDeleting Success: ${deletingResult}" --type "Info"
excelClose --file ${excelFile}
// The above example returns the following output:
// Deleted Rows Quantity: 1
// Deleting Success: True

Example 2: Command deletes rows that have the value "IBM Robotic Process Automation" in the "Company" column, returning "True" to indicate operation success and the number of rows deleted.

defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
defVar --name deletingResult --type Boolean
defVar --name deletedRowsQuantity --type Numeric
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCityDelete.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet  --entiretable  --hasheaders  excelTable=value
//
deleteRows --where "Company = \'IBM Corporation\'" --dataTable ${excelTable} deletingResult=success deletedRowsQuantity=changedrowscount
logMessage --message "Deleted Rows Quantity: ${deletedRowsQuantity}\r\nDeleting Success: ${deletingResult}" --type "Info"
excelClose --file ${excelFile}
// The above example returns the following output:
// Deleted Rows Quantity: 2
// Deleting 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 Indexes parameter or Where parameter, so that there are no values in both parameters simultaneously.

See Also

  • Add Column
  • Add Row
  • Check for Column Existence in Table
  • Copy Rows
  • Copy Table
  • Delete Column
  • 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
  • Move Table Rows
  • Sort Table
  • Update Row
  • Write Table to File