# Change a single value of a cell with a script

**URL:** <https://forum.inductiveautomation.com/t/change-a-single-value-of-a-cell-with-a-script/10276>\
**Category:** Ignition\
**Created:** [July 24, 2015, 7:06pm UTC](https://forum.inductiveautomation.com/t/change-a-single-value-of-a-cell-with-a-script/10276 "2015-07-24T19:06:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [July 24, 2015, 7:06pm UTC](https://forum.inductiveautomation.com/t/change-a-single-value-of-a-cell-with-a-script/10276/1 "2015-07-24T19:06:09Z")

</div>

I currently have a window that has some text fields that get submitted into a chart when i click submit. I can then double click on the row of the table and it will pull all the information back into the text fields. This is great, however, when I click submit with new data, it just creates a new row in the table.

I’m writing an ‘update’ script for a button for my table. I see that there is a function called updateRow and I was wondering if there was a simpler solution? ❓ If there is not a simpler solution, is it necessary that I convert my table to a Pydataset first or can I work with the raw values of my table?

I have tried changing a single cell using something like this:

data.getValue(selectedRows, “Action Item”) = string

but this always returns an error saying: SyntaxError: (“can’t assign to function call”, (", 11, 0, ‘data.getValue(selectedRows, “Action Item”) = string\n’))

Thanks in Advance for the help! ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 24, 2015, 7:15pm UTC](https://forum.inductiveautomation.com/t/change-a-single-value-of-a-cell-with-a-script/10276/2 "2015-07-24T19:15:13Z")

</div>

Hi alewayhar,

See the documentation for the [system.dataset.setValue](https://support.inductiveautomation.com/usermanuals/ignition/index.html?system_dataset_setvalue.htm) function.

Here is the example the documentation gives:

```auto
table = event.source.parent.getComponent("Table")
selRow = table.getSelectedRow()
selCol = table.getSelectedColumn()
if selRow != -1 and selCol != -1:
   newData = system.dataset.setValue(table.data, selRow, selCol, 0.0)
   table.data = newData
```

---

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [July 24, 2015, 7:22pm UTC](https://forum.inductiveautomation.com/t/change-a-single-value-of-a-cell-with-a-script/10276/3 "2015-07-24T19:22:21Z")

</div>

Do you know if this is possible to do just for the entire row? Not just changing a single cell, but expanding it to change the entire row?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 24, 2015, 7:34pm UTC](https://forum.inductiveautomation.com/t/change-a-single-value-of-a-cell-with-a-script/10276/4 "2015-07-24T19:34:49Z")

</div>

The system.dataset.updateRow function is a simple solution.

Convert the row you want to change in the table into a list, modify the list and then create a new dataset with the changed row.

Example:

`table = event.source.parent.getComponent("Table")
rowIndex = table.selectedRow
row = list(system.dataset.toPyDataSet(table.data)[rowIndex])
#change the row
row[2] = "new data" 
row[0] = 10
#convert the row into a python dictionary
columns = list(table.data.getColumnNames())
row = dict(zip(columns,row))
#create a new dataset with the changed row and assign it to the table
table.data = system.dataset.updateRow(table.data, rowIndex, row)`

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 24, 2015, 7:35pm UTC](https://forum.inductiveautomation.com/t/change-a-single-value-of-a-cell-with-a-script/10276/5 "2015-07-24T19:35:41Z")

</div>

system.dataset.updateRow() will do that for you.

[code]selRow = table.getSelectedRow()  
if selRow != -1:  
dataIn = event.source.parent.getComponent(“Table”).data  
point1 = event.source.parent.getComponent(“TextBox1”).text  
point1 = event.source.parent.getComponent(“TextBox2”).text  
point1 = event.source.parent.getComponent(“TextBox3”).text

updates = {“colName1” : point1, “colName2” : point2, “colName3” : point3}

dataOut = system.dataset.updateRow(dataIn, selRow, updates)  
event.source.parent.getComponent(“Table”).data=dataOut[/code]

EDIT Nick beat me to it! 😉
