Skip to main content
Version: 7.9

system.dataset.addRows

This function is used in Python Scripting.

Description

Takes a dataset and returns a new dataset with new rows added or inserted into it. Datasets are immutable, so it is important to realize that this function does not actually add rows to a dataset. You'll need to do something with the new dataset that this function creates to achieve something useful. If the rowIndex argument is omitted, the rows will be appended to the end of the dataset.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.dataset.addRow(dataset [, rowIndex], row)

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.
introwIndexThe index (starting at 0) at which to insert the new row. Will throw an IndexError if less than zero or greater than the length of the dataset. If omitted, the new row will be appended to the end. [optional]
PySequencerowA Python sequence representing the data for the new rows. Its length must equal the number of columns in the dataset.

Returns

Dataset - A new dataset with the new tow inserted or appended.

Scope

All

Code Examples

Example 1
# This example would add new options to a Dropdown List by adding a row to its underlying dataset.
# Note that the last line assigns the return value of the addRows function to the dropdown's data property.

dropdown = event.source.parent.getComponent("Dropdown")
newRow = [[5, "New Option"], [6, "Another New Option"]]
dropdown.data = system.dataset.addRows(dropdown.data, newRow)
Example 2
# This snippet would add new options into a Dropdown component just like above, but at the beginning:

dropdown = event.source.parent.getComponent("Dropdown")
newRow = [[5, "New Option"], [6, "Another New Option"]]
dropdown.data = system.dataset.addRows(dropdown.data, 0, newRow)