Skip to main content
Version: 8.1

system.dataset.addRow

This function is used in Python Scripting.

Description​

Takes a dataset and returns a new dataset with a new row added or inserted into it. If the rowIndex argument is omitted, the row will be appended to the end of the dataset.

note

Datasets are immutable, which means they cannot be directly modified once created. Instead, this scripting function returns a new dataset with some modification applied, which must be assigned to a variable to be used. See Altering a 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.
IntegerrowIndexThe 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]
List[Any]rowA Python list representing the data for the new row. Its length must equal the number of columns in the dataset.

Returns​

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

Scope​

Gateway, Vision Client, Perspective Session

Code Examples​

Code Snippet
# This example would add a new option to a Vision Dropdown List by adding a row to its underlying dataset.
# Notice how the last line assigns the return value of the addRow function to the dropdown's data property.

# This script should be on a button that is a sibling to a Dropdown List component named "Dropdown".
dropdown = event.source.parent.getComponent("Dropdown")
newRow = [5, "New Option"]
dropdown.data = system.dataset.addRow(dropdown.data, newRow)
Code Snippet
# This snippet would add a new option into a Dropdown component just like above, but at the beginning:
dropdown = event.source.parent.getComponent("Dropdown")
newRow = [5, "New Option"]
dropdown.data = system.dataset.addRow(dropdown.data, 0, newRow) # Note that rowIndex is passed in

Keywords​

system dataset addRow, dataset.addRow