Skip to main content
Solved

TestConditions in TestFilter , does not support list elements index range in Test Clauses


samisnunu
Contributor
Forum|alt.badge.img+10

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?

Best answer by redgeographics

samisnunu wrote:

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

View original
Did this help you find an answer to your question?

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+48

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.


caracadrian
Contributor
Forum|alt.badge.img+23
  • Contributor
  • October 19, 2021

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.


samisnunu
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • October 19, 2021

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)


redgeographics
Celebrity
Forum|alt.badge.img+48
  • Celebrity
  • Best Answer
  • October 19, 2021
samisnunu wrote:

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


samisnunu
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • October 19, 2021
redgeographics wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings