# What's the best way to update a dataset and write it back to template parameters?

**URL:** <https://forum.inductiveautomation.com/t/whats-the-best-way-to-update-a-dataset-and-write-it-back-to-template-parameters/108795>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [July 22, 2025, 10:22pm UTC](https://forum.inductiveautomation.com/t/whats-the-best-way-to-update-a-dataset-and-write-it-back-to-template-parameters/108795 "2025-07-22T22:22:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [July 22, 2025, 10:22pm UTC](https://forum.inductiveautomation.com/t/whats-the-best-way-to-update-a-dataset-and-write-it-back-to-template-parameters/108795/1 "2025-07-22T22:22:09Z")

</div>

I would like to update all the values in one column of the dataset, coming from the template parameters of the Template Repeater.

Using `setValue()` returns a new dataset each time. So, how can I change all the values at once, then push that back to the Repeater's template params? Do I need to convert to a list or dict and back to dataset?

Thanks

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 22, 2025, 10:32pm UTC](https://forum.inductiveautomation.com/t/whats-the-best-way-to-update-a-dataset-and-write-it-back-to-template-parameters/108795/2 "2025-07-22T22:32:45Z")

</div>

The trick is to create a new list of values in one operation, then use our system functions to slice off the old column and drop in a new one. See this thread for a possible approach:

> [@Can I modify an entire column from a dataset with system.dataset.setValue()?](https://forum.inductiveautomation.com/t/can-i-modify-an-entire-column-from-a-dataset-with-system-dataset-setvalue/87043/3):
>
> def mapColumn(function, dataset, column): if isinstance(column, basestring): column = dataset.getColumnIndex(column) columnData = map(function, dataset.getColumnAsList(column)) columnsToKeep = range(dataset.columnCount) columnsToKeep.pop(column) dsWithoutColumn = system.dataset.filterColumns(dataset, columnsToKeep) return system.dataset.addColumn( dsWithoutColumn, column, columnData, dataset.getColumnName(column), dataset.getColumnType(column) ) It's relatively easy to…

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [July 23, 2025, 1:18am UTC](https://forum.inductiveautomation.com/t/whats-the-best-way-to-update-a-dataset-and-write-it-back-to-template-parameters/108795/3 "2025-07-23T01:18:33Z")

</div>

Thanks Paul!

Is there a way to pull a row into a list as well?

Edit:  
Got it. Just had to remember this is a `pyDataset`.

```python
row_list = []
for row in pyDS:
	if row[0] == myZone:
		row_list = row

```

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [July 23, 2025, 1:43am UTC](https://forum.inductiveautomation.com/t/whats-the-best-way-to-update-a-dataset-and-write-it-back-to-template-parameters/108795/4 "2025-07-23T01:43:08Z")

</div>

Is there a row index function for py datasets?

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [July 23, 2025, 1:56am UTC](https://forum.inductiveautomation.com/t/whats-the-best-way-to-update-a-dataset-and-write-it-back-to-template-parameters/108795/5 "2025-07-23T01:56:02Z")

</div>

just use pyDS[the number of index]. For example,pyDS[0]

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 23, 2025, 2:31am UTC](https://forum.inductiveautomation.com/t/whats-the-best-way-to-update-a-dataset-and-write-it-back-to-template-parameters/108795/6 "2025-07-23T02:31:02Z")

</div>

If you really need the row index then you can use `enumerate` to return an index and the row.

```python
row_list = [[i,row] for i,row in enumerate(pyDs) if row[0] == myZone]

```

Obviously a contrived example to demonstrate both how to get an index number and how to compress the simple for loop into a comprehension.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [July 23, 2025, 9:07pm UTC](https://forum.inductiveautomation.com/t/whats-the-best-way-to-update-a-dataset-and-write-it-back-to-template-parameters/108795/7 "2025-07-23T21:07:19Z")

</div>

I will give that a try.  
@nideyijuyidong  
Since the PyRow is not aware of it's own row index number, and using `range()` to loop through the dataset does not provide a list of row data (for a singled out row), I had to look for another option.

@lrose I had a hunch it might involve `enumerate(). I appreciate the "contrived example"! 🙂
