Problem to filter dataset

Hello I have this dataset:
And I would like filtering row of my dataset where zone =A

I want obtain this data below :

how can I filtering it please.

Is this Vision or perspective? Where is the dataset coming from?

def filter_dataset(ds, condition):
	return system.dataset.toDataSet(list(ds.columnNames), filter(condition, system.dataset.toPyDataSet(ds)))

filter_dataset(ds, lambda row: row['zone'] == 'A')
1 Like

Thank you, pascal for your anwser. How can whrite without use function please


Please explain what you are trying to do.

1 Like

I want use something like

I don't want use function beacause I wand return this dataset on Scrit Transformation this why I don't need use function.

put the filter function in your project scripts library

1 Like

it work but there is two function on the Script transformation

Thank you Victor I juste have so much function there that is why I don't nedd put there.

You can nest functions in Python. It's fine. You also don't have to encapsulate it as a function:

def transform(self, value, quality, timestamp):
	return system.dataset.toDataSet(
		filter(lambda row: row['zone'] == 'A', system.dataset.toPyDataSet(ds))
1 Like

Thank you very much, this suits me better

Honestly, it looks suspiciously like you'll be utilizing this function in multiple places. You really should generalize it further so that you only have to maintain it in one place (Project Script Library).

I would suggest this:

def filterDataset(ds,columnName,filterValue):
    return system.dataset.toDataSet(
        filter( lambda row: row[columnName] == filterValue,

Then your transform for say Zone B would look like:

def transform(self,value,quality,timestamp):
    return projectLibrary.filterDataset(value,'zone','B')
1 Like

Or maybe an expression binding instead of tag binding? No transform at all. Like this:

where({[AR]A-VMS/camAdresse}, it()['VOIE'] = 'A')

Via my latest Simulation Aids (free!).


Or system.dataset.filter from Ignition Extensions, as long as we're plugging modules :slight_smile:
Phil's is going to be faster, though.


Hello, thank you for all your proposition. This help me so much to filter my data.
But I have Other question.
If I want get index of row were value of column table = 5, how can I do it.

column_index = ds.getColumnIndex('table')
column_values = ds.getColumnAsList(column_index)
index_of_five = column_values.index(5)

or, to make things simpler:

def find_in_ds(ds, column, value):
	return ds.getColumnAsList(ds.getColumnIndex(column)).index(value)

find_in_ds(ds, 'table', 5)

But why, though ? Why do you need the index ? What are you trying to do ?
If you want to retrieve values from a particular row in a dataset, the lookup expression functions is what you want:

1 Like

I have filtered a dataset and I would like to find index of each row value , that is why I need the index

That doesn't tell me why you want the index.

1 Like

I have a webcam set on a Vue.
Each webcam has an url address and an ID
I have a vCam view
On this view, I have a dataset on CUSTOM .
On the vCam View , I have an ID parameter, and pCount

pCount must get the index of the table ID set on parameter

And I I send the dataset, ID and pCount in a Popup

Each webcam Have a Popup, when user clique on an webcam, I want kown index row of url ou ID on the dataset.

Consider passing the whole row of the dataset as one parameter into the popup view.

1 Like