Skip to main content
Version: 7.9

system.dataset.deleteRows

This function is used in Python Scripting.

Description

Takes a dataset and returns a new dataset with one or more rows removed. Datasets are immutable, so it is important to realize that this function does not actually remove the rows from the argument dataset. You'll need to do something with the new dataset that this function creates to achieve something useful.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.dataset.deleteRows(dataset, rowIndices)

Parameters

TypeParameterDescription
DatasetdatasetThe starting dataset. Please be aware that this dataset will not actually be modified (datasets are immutable), but rather will be the starting point for creating a new dataset.
int[]rowIndicesThe indices (starting at 0) of the rows to delete. Will throw an IndexError if any element is less than zero or greater than the number of rows in the dataset - 1.

Returns

Dataset - A new dataset with the specified rows removed.

Scope

All

Code Examples

Example 1
# This example would remove several rows from a Table component, by re-assigning the Table's data property to the new dataset returned by thedeleteRows function.

ds = event.source.parent.getComponent('Table').data
rows = [0,2,3,4]
ds = system.dataset.deleteRows(ds, rows)
event.source.parent.getComponent('Table').data = ds
Example 2
# This example will demonstrate one approach of deleting every row in a dataset.

# Start with the original dataset. In this example we're assuming a Power Table exists on the same window as this script.
table = event.source.parent.getComponent('Power Table')

# Create a List that will act as the indices. We're using the getRowCount function so we know what the maximum index in the list should be.
rowIndices = range(table.data.getRowCount())

# Call system.dataset.deleteRows, using the Data property on the power table as the base.
newDS = system.dataset.deleteRows(table.data, rowIndices)

# Assign the new empty dataset back to the Power Table
table.data = newDS