Skip to main content
Solved

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

  • October 18, 2021
  • 5 replies
  • 109 views

samisnunu
Contributor
Forum|alt.badge.img+12

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

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+59
  • Celebrity
  • 3700 replies
  • October 18, 2021

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
  • 571 replies
  • 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+12
  • Author
  • Contributor
  • 65 replies
  • 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+59
  • Celebrity
  • 3700 replies
  • Best Answer
  • 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)

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+12
  • Author
  • Contributor
  • 65 replies
  • October 19, 2021

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