Deleting all rows in a Dataset (except its header) by Script

Hi guys,

(This is my first post)

Is there any way in Ignition where we can delete all existing rows in a date set using a script?

I know system.dataset.deleteRows(dataset, rowIndices) can delete the rows in the dataset given the dataset and row indices. But if we were to delete all at once (except the header), is there an easier way?

Thank you for your help!

This should work on any dataset:

ds = event.source.parent.getComponent('Table').data headers = list(ds.getColumnNames()) dataOut=[] event.source.parent.getComponent('Table').data=system.dataset.toDataSet(headers,dataOut)

1 Like

Sorry for my manners. Usually I welcome people first… :blush:

Anyway, welcome to the forums! :mrgreen:

Unfortunately, using toDataset() with an empty list won’t retain the column datatypes. For that, you need something like this:from com.inductiveautomation.ignition.common import BasicDataset ds = event.source.parent.getComponent('Table').data ds0 = BasicDataset(ds.getColumnNames(), ds.getColumnTypes(), None)

Hi Jordan & pturmel,

Thanks! Those work! :astonished: I am still new to Ignition, thus many things I got to figure out yet.

@Jordan: no worries about mannerism, you have helped me! :slight_smile:

Regards,
ian

A post was split to a new topic: Display custom message when Perspective Table has no data