# Script transform giving ScriptEval errors with seemingly valid dictionary manipulation

**URL:** <https://forum.inductiveautomation.com/t/script-transform-giving-scripteval-errors-with-seemingly-valid-dictionary-manipulation/25304>\
**Category:** Ignition\
**Created:** [May 24, 2019, 2:59pm UTC](https://forum.inductiveautomation.com/t/script-transform-giving-scripteval-errors-with-seemingly-valid-dictionary-manipulation/25304 "2019-05-24T14:59:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [May 24, 2019, 2:59pm UTC](https://forum.inductiveautomation.com/t/script-transform-giving-scripteval-errors-with-seemingly-valid-dictionary-manipulation/25304/1 "2019-05-24T14:59:41Z")

</div>

I have data from a Query Binding being sent as JSON to a script transform and the data looks like this:

```
[ { 'source': 'beginning:end', 'count': 5}, 
  { 'source': 'beginning2:end2', 'count': 10}]

```

My goal is to get it to look like this:

```
[ { 'source': 'end', 'count': 5}, 
  { 'source': 'end2', 'count': 10}]

```

And I’m using the following script transform code within the transform function to try to accomplish this:

```
for x in value:
	x['source'] = x['source'].split(':')[-1]

return value

```

I’ve tested this in the Scripting Console, in online REPLs and this code does exactly what I want. However, I always get `Error_ScriptEval` in the Binding Preview when trying to actually use this code as a script transform.

I’m stumped, any ideas as to what is going wrong here?

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [May 24, 2019, 3:30pm UTC](https://forum.inductiveautomation.com/t/script-transform-giving-scripteval-errors-with-seemingly-valid-dictionary-manipulation/25304/2 "2019-05-24T15:30:01Z")

</div>

You can’t modify the value passed in.

```auto
	newValues = []
	for x in value:
		newValue = {}
		for k, v in x.iteritems():
			if k == "source":
				newValue[k] = v.split(':')[-1]
			else:
				newValue[k] = v
		
		newValues.append(newValue)
	
	return newValues

```

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [May 24, 2019, 3:32pm UTC](https://forum.inductiveautomation.com/t/script-transform-giving-scripteval-errors-with-seemingly-valid-dictionary-manipulation/25304/3 "2019-05-24T15:32:24Z")

</div>

Well that explains it, and fixed the problem. Thank you!

---

<div class="post-metadata">

**Author:** ![Oscar\_Simon](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@Oscar\_Simon](https://forum.inductiveautomation.com/u/Oscar_Simon)\
**Post date:** [September 9, 2024, 11:42pm UTC](https://forum.inductiveautomation.com/t/script-transform-giving-scripteval-errors-with-seemingly-valid-dictionary-manipulation/25304/4 "2024-09-09T23:42:35Z")

</div>

I ran into the same issue but then I found that It's important to note that the dataset passed to the script is an Ignition dataset, which is immutable and presented as an enumerator. To manipulate the data, you need to convert it to a `PyDataset` using the `system.dataset.toPyDataSet(value)` function. This conversion allows you to work with the data in a more flexible format, enabling you to perform any desired manipulations. I hope this clears up things for someone else.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 10, 2024, 12:14am UTC](https://forum.inductiveautomation.com/t/script-transform-giving-scripteval-errors-with-seemingly-valid-dictionary-manipulation/25304/5 "2024-09-10T00:14:31Z")

</div>

Same reply as I made over here:

> [@Parse Error in Script Transform After List of Dictionaries Manipulation](https://forum.inductiveautomation.com/t/parse-error-in-script-transform-after-list-of-dictionaries-manipulation/58310/8):
>
> A PyDataset is a thin wrapper around a general Dataset, and is therefore also immutable. But it presents a dataset in jython as a python-like list of lists, which is quite handy when constructing a new dataset with modified content.
