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