How to use Datasets tags with python scripts

Hello.

I want to create a dataset tag to store certain values as in a table from a value change script and I can not find any examples in the documentation.

Can someone post an example of how to insert, delete and read rows from a dataset.

It's all here:

Do note that datasets must not be modified in place. Modifications, whether via those functions or otherwise, create a complete new dataset that is to be written back to the source.

Also a video that might be helpful for you.

1 Like

Hello.

I do not understand the objective of the Datasets if are mostly immutable.

Or I am not understanding properly.

That datasets are immutable, really only means that they can not be modified in place. This doesn't mean that they cant be used.

For instance to add rows you would use system.dataset.addRows() this function takes a dataset and the rows you want to add, and returns a new dataset object that has all of the previous datasets rows plus those you wanted added.

There are similar methods for adding/removing columns, and removing rows.

The key to the rule is that Ignition's event system, which drives all subscription and binding technologies, needs to focus on objects that know when they are changing, so they can notify interested parties (bindings). Individual cells of a dataset cannot do this, nor can members of document tags. For such objects, the notification trigger is replacement of the object--the whole thing.

It is possible to change such things in place, but nothing else will notice.

1 Like

Ok, now I got it.