# Remove "" From UpdateRow changes

**URL:** <https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532>\
**Category:** Ignition\
**Created:** [July 12, 2019, 9:04pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532 "2019-07-12T21:04:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick.shea](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@nick.shea](https://forum.inductiveautomation.com/u/nick.shea)\
**Post date:** [July 12, 2019, 9:04pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532/1 "2019-07-12T21:04:08Z")

</div>

Hello,  
I’m trying to use `system.dataset.updateRow` and I am running into a small problem.

```auto
updates = {"Number":'{"style":{"backgroundColor":"#FFFF00"},"value":"44"}'}
		newPen = system.dataset.updateRow(pyData,1,updates)
		pyData = newPen
		
		return pyData

```

The problem is that when I go to check this row in the designer number has the following value

```auto
  "Number": "{\"style\":{\"backgroundColor\":\"#FFFF00\"},\"value\":\"44\"}",

```

And I need to instead be

```auto
  "Number": {"style":{"backgroundColor":"#FFFF00"},"value":"44"}",

```

How could I format `updates` to not do this?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 12, 2019, 9:11pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532/2 "2019-07-12T21:11:55Z")

</div>

> [@nick.shea](#):
>
> updates = {"Number":'{"style":{"backgroundColor":"#FFFF00"},"value":"44"}'}

should be

```auto
updates = {"Number":{"style":{"backgroundColor":"#FFFF00"},"value":"44"}}

```

(remove the single-quotes)

---

<div class="post-metadata">

**Author:** ![nick.shea](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@nick.shea](https://forum.inductiveautomation.com/u/nick.shea)\
**Post date:** [July 12, 2019, 9:13pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532/3 "2019-07-12T21:13:30Z")

</div>

> [@cmallonee](#):
>
> {"Number":{"style":{"backgroundColor":"#FFFF00"},"value":"44"}}

Unfortunatly that makes the problem a bit worse, result:

```auto
  "Number": "{\u0027style\u0027: {\u0027backgroundColor\u0027: \u0027#FFFF00\u0027}, \u0027value\u0027: \u002743\u0027}",

```

It also doesn't remove the first/last "

---

<div class="post-metadata">

**Author:** ![nick.shea](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@nick.shea](https://forum.inductiveautomation.com/u/nick.shea)\
**Post date:** [July 12, 2019, 9:41pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532/4 "2019-07-12T21:41:27Z")

</div>

To put the problem another way, I need to change the Dictionary Key from a value to an object, then insert 2 things into it. The first being a the value, and the second being an object(style), then I need to insert the backgroundColor value into the style object.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 12, 2019, 11:08pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532/5 "2019-07-12T23:08:32Z")

</div>

After looking at some previous threads we’ve interacted on, I’m going to assume this is an attempt at inserting a `style` object into a dataset, which you’re then trying to apply to a table’s data.

First things first:  
From the [docs](https://docs.inductiveautomation.com/display/DOC80/system.dataset.updateRow), `system.dataset.updateRow(pyData,1,updates)` can only be used to change values for existing columns, so if “style” isn’t already in the dataset, you can’t add it. In the same way, you’d be unable to add backgroundColor because it doesn’t already exist. Situations like yours expose the limitations of datasets dealing with datasets directly.

Solution:  
Convert the dataset into a python object, make your changes, and then send along this new object (or convert it back into a dataset and then send it along).

Try:

```auto
my_data = system.dataset.toPyDataSet(pyData)
for i in range(len(my_data)):
    # perform some logic here
    my_data[i]["style"] = {"backgroundColor": "#FFFF00"}
# this would return the PyDataSet
return my_data 
# or
# this would return the modified data as a Dataset
# return system.dataset.toDataSet(my_data)

```

---

<div class="post-metadata">

**Author:** ![nick.shea](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@nick.shea](https://forum.inductiveautomation.com/u/nick.shea)\
**Post date:** [July 15, 2019, 3:23pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532/6 "2019-07-15T15:23:19Z")

</div>

Morning @cmallonee,  
I tried what you suggested and received the following error:  
TypeError:‘com.undictuveautimation.ignition.common.script.builtin.DatasetUtilities$PyDataSet$PyRow’ object does not support item assignment  
I played around with using a standard db instead of a pyDb as well which yielded a similar error message saying that it’s unsubscriptable.  
Would there be any other way to try this?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 15, 2019, 4:11pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532/7 "2019-07-15T16:11:44Z")

</div>

Disclaimer: the upcoming solution is terrible, and we’re aware this area needs improvement specifically due to cases like this.

Instead of returning the query data with auto or dataset, change the Return Format dropdown to “json”, then use the following code as an example.

```auto
my_data = [row.toDict() for row in value]
for i in range(len(my_data)):
    # perform some logic here
    my_data[i]["style"] = {"backgroundColor": "#FFFF00"}
return my_data 

```

---

<div class="post-metadata">

**Author:** ![nick.shea](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@nick.shea](https://forum.inductiveautomation.com/u/nick.shea)\
**Post date:** [July 15, 2019, 5:59pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532/8 "2019-07-15T17:59:09Z")

</div>

@cmallonee  
Thanks for the quick reply.  
I have been playing around with your solution for a little while now, but unfortunately in this implementation ignition attempts to create a new column “style” and this actually doesn’t apply the backgroundColor.  
What I believe needs to be done is modify the JSON of each column in each row to apply the style.  
This is what I have been trying to do but I have little experience with JSON and python so it’s taking me a while.

---

<div class="post-metadata">

**Author:** ![nick.shea](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@nick.shea](https://forum.inductiveautomation.com/u/nick.shea)\
**Post date:** [July 15, 2019, 9:26pm UTC](https://forum.inductiveautomation.com/t/remove-from-updaterow-changes/26532/9 "2019-07-15T21:26:39Z")

</div>

@cmallonee  
Finally have a way to do it if you are interested  
I basically created a new dataset and did the following

```auto
newDataset.append({"Order Timeline":{"value":pyData[row][1],"style":{"backgroundColor": rowColor}}

```
