Skip to main content

In TestFilter, is there a trick to allow specifying the list index range in the Test Clause?

e.g., _list{[0-2]}.fruit = 'Apple'

rather than specifying each element index to test for individually:

_list{0}.fruit = 'Apple'

AND _list{1}.fruit = 'Apple'

AND _list{2}.fruit = 'Apple'

without going into PythonCaller way?

You can try the ListSearcher instead, it'll return the list index where it's found and you can then test whether it's in your range.


You can create a custom transformer and use ListRangeExtractor to get the range of the list then iterate through the list and test each element.

Or you can explode the list via ListExploder, check each element and/or create aggregates then use only the features that pass the test you need.

Come to think of it this would be a nice idea to implement in FME.


Thanks @Hans van der Maarel​  and @caracadrian​ ,

The approaches you propose can work , but requires additional transformers, while the idea is for enhancements and reducing the clutter around..

Anyways, @andrea (safe) also has suggested me adding an idea for this implementation, here: (https://community.safe.com/s/idea/0874Q000000cTvgQAE/detail)


Thanks @Hans van der Maarel​  and @caracadrian​ ,

The approaches you propose can work , but requires additional transformers, while the idea is for enhancements and reducing the clutter around..

Anyways, @andrea (safe) also has suggested me adding an idea for this implementation, here: (https://community.safe.com/s/idea/0874Q000000cTvgQAE/detail)

If you want to do it all within one Tester or TestFilter you can still do it in a single line by using the CONTAINS operator on a concatenation of the list elements you want (probably should separate those), like this:

 

Screenshot 2021-10-19 at 11.25.56


If you want to do it all within one Tester or TestFilter you can still do it in a single line by using the CONTAINS operator on a concatenation of the list elements you want (probably should separate those), like this:

 

Screenshot 2021-10-19 at 11.25.56

Awesome, that's the trick! 😉

Thank you @Hans van der Maarel​ , edit it from within the its text Editor, now I could write it in within one line (although a bit long line)..

image 

image.png


Reply