system.dataset.updateRow
This function is used in Python Scripting.
Description​
Takes a dataset and returns a new dataset with a one row altered. To alter the row, this function takes a Python dictionary to represent the changes to make to the specified row. The keys in the dictionary are used to find the columns to alter.
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.updateRow(dataset, rowIndex, changes)
Parameters​
Type | Parameter | Description |
---|---|---|
Dataset | dataset | The starting dataset. Will not be modified (datasets are immutable), but acts as the basis for the returned dataset. |
Integer | rowIndex | The index of the row to update (starting at 0). |
Dictionary[String, Any] | changes | A dictionary of changes to make. The keys in the dictionary should match column names in the dataset, and their values will be used to update the row. |
Returns​
Dataset - A new dataset with the values at the specified row updated according to the values in the dictionary.
Scope​
Gateway, Vision Client, Perspective Session
Code Examples​
# This example could be used to dynamically change the data that an Easy Chart displays.
# In this simple example, we assume that the chart is always configured to display a single tank's level.
# This script updates the pen being displayed using a dynamic tank number.
# Generate new tag name and tag path.
tankNumber = 5
newName = "Tank %d Level" % tankNumber
newPath = "Tanks/Tank %d/Level" % tankNumber
# Consolidate changes into a dictionary.
updates = {"NAME": newName, "TAG_PATH":newPath}
# Update the Easy Chart.
chart = event.source.parent.getComponent("Easy Chart")
newPens = system.dataset.updateRow(chart.tagPens, 0, updates)
chart.tagPens = newPens