Solved

Search entire attribute table for the existence of a particular string

  • 13 March 2023
  • 6 replies
  • 27 views

Badge +1

Hi I have a feature service that is apart of a Survey123 survey. The survey will indicate if something has failed in a variety of ways.

 

I currently have a workspace that has a testfilter transformer looking through 50 different attribute columns looking for the word Fail. Then from each output port there is an action that is taken. Is there a transformer that I could use to search the whole attribute table for the word fail instead?

 

Thanks!

icon

Best answer by ebygomm 14 March 2023, 17:18

View original

6 replies

Userlevel 2
Badge +17

Hi @abysmal-ukulele​,

Please have a look at the FME Hub transformer AttributeValueSearcher. I think it is exactly what you are looking for.

Userlevel 1
Badge +21

If the attribute will only contain the word Fail and nothing else you could use an attributevalidator. Test for Contains Regex and only pass items where the attribute does not equal Fail. 

^(?!Fail$).*$

 Any features with an attribute equalling Fail will pass through the Failed port, the attributes containing the word fail will be detailed in a list

 

I think this regex should work if you just want to look for the word Fail but probably needs checking!

^(?!.*\bFail\b).*$

 

Badge +1

If the attribute will only contain the word Fail and nothing else you could use an attributevalidator. Test for Contains Regex and only pass items where the attribute does not equal Fail. 

^(?!Fail$).*$

 Any features with an attribute equalling Fail will pass through the Failed port, the attributes containing the word fail will be detailed in a list

 

I think this regex should work if you just want to look for the word Fail but probably needs checking!

^(?!.*\bFail\b).*$

 

Hi @ebygomm​, I'm afraid I'm really new to this.  The line of code is what I would type into what? Am I using a tester transformer with that code?

Userlevel 1
Badge +21

Hi @ebygomm​, I'm afraid I'm really new to this. The line of code is what I would type into what? Am I using a tester transformer with that code?

image

Badge +1

Hi @ebygomm​, I'm afraid I'm really new to this. The line of code is what I would type into what? Am I using a tester transformer with that code?

Thanks again @ebygomm​  I like your suggestion. I'm debating how to create my workspace. I could use the attribute validator or I have also created a TestFilter that has close to 50 cases. I'm debating which of the two methods would be more sustainable to maintain vs. will be processed faster.

Badge +1

Hi @abysmal-ukulele​,

Please have a look at the FME Hub transformer AttributeValueSearcher. I think it is exactly what you are looking for.

Hi @daveatsafe​ unfortunately I can't use this on our production environment. But I think you're right the transformer looks promising. Cheers!

Reply