TSTool / Command / DeleteTableRows
Overview
The DeleteTableRows
command deletes specified rows from a table using one of the following approaches:
- Condition:
- delete rows where a column value matches a condition
- Row Number:
- delete specific row numbers
- delete all rows
- delete first N or last N rows, useful when used with the
SortTable
command to process the first or last item(s) in a table
Because the deletion is a destructive action, only one of the above conditions is required to be specified. The number of rows deleted and the table row count after the delete can be set as processor properties so that the delete can be checked.
Command Editor
The command is available in the following TSTool menu:
- Commands(Table) / Manipulate Table Values
The following dialog is used to edit the command and illustrates the syntax of the command.
DeleteTableRows
Command Editor for Condition Parameter (see full-size image)
DeleteTableRows
Command Editor for Row Number Parameters (see full-size image)
DeleteTableRows
Command Editor for Output Properties Parameters (see full-size image)
Command Syntax
The command syntax is as follows:
DeleteTableRows(Parameter="Value",...)
Command Parameters
Tab | Parameter | Description | Default |
---|---|---|---|
All | TableID required |
The table identifier for the table to process. Can specify with ${Property} . |
None - must be specified. |
Condition | Condition |
A condition to match rows to be deleted. Can use ${Property} to specify row number. See additional information in the Tables appendix. |
|
Row Number | DeleteRowNumbers |
The row number(s) to delete:
Can use ${Property} . |
|
First |
|
||
Last |
|
||
Output Properties | DeleteCountProperty |
The name of a property to set to the number of rows deleted. | |
RowCountProperty |
The name of a property to set to the number of table rows after the delete. |
Examples
See the automated tests.
A simple comma-separated-value data as follows can be read with ReadTableFromDelimitedFile
:
# Simple table for testing
"string1","double1","integer1"
"String1",1.0,1
"String2",2.0,2
"String3",3.0,3
The command file to read the above file and remove the first and last rows is as follows:
ReadTableFromDelimitedFile(TableID="Table1",InputFile="testtable.csv")
DeleteTableRows(TableID="Table1",DeleteRowNumbers="1")
DeleteTableRows(TableID="Table1",DeleteRowNumbers="last")
Troubleshooting
See the main TSTool Troubleshooting documentation.
See Also
DeleteTableColumns
commandReadTableFromDelimitedFile
commandSortTable
command