Skip to main content
Question

How do I test/filter attributes using a list with wildcards?

  • December 11, 2021
  • 7 replies
  • 188 views

ronmak
Contributor
Forum|alt.badge.img

I am processing a large amount of simple data: Points with attributes. I want to filter the data by a specific set of attributes, some of which have wild cards. e.g., "T", "T BASE", "T BENT" should all pass through. For each run, a user will be specifying the valid attributes by putting them into a file (probably text), which will be read in at the start of the process. I mention using a list, but they could go into a table as well if that would work better.

7 replies

geogaard
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 12, 2021

Would something like this work for you:

Using the tester with the IN operator will check the attribute against a list of valid values. This list could be populated from a table or a text file.

 

bilde.png


ronmak
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • December 14, 2021

I like this, though the weakness is that all possibilities need to be specified. The user may not know all of the possible suffixes that come after the "T".

But it get me thinking that I could first extract the first 'word' (text before the first space) from each attribute and test those.

In the Tester parameters example you give above, can auto-fill in the "Right Value" from the contents of a text file?


geogaard
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 16, 2021
ronmak wrote:

I like this, though the weakness is that all possibilities need to be specified. The user may not know all of the possible suffixes that come after the "T".

But it get me thinking that I could first extract the first 'word' (text before the first space) from each attribute and test those.

In the Tester parameters example you give above, can auto-fill in the "Right Value" from the contents of a text file?

Yes, you could certainly use the AttributeSplitter with a space as the delimter and test the second part in the tester.

 

To add the values to test against you have to read that from somwhere. Do you already have a list of possible values? For example lets say you have all the words in a text file. This file could be read in and merged into each feature with the FeatureMerger and then you could pick the list of attributes to test against. It would look something like this:

bilde


dustin
Influencer
Forum|alt.badge.img+30
  • Influencer
  • December 16, 2021

I'd vote regex. If it's always 'T' or 'T' followed by a space and 4 capitalized letters, you could use this:

 

image


ronmak
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • December 17, 2021
geogaard wrote:

Yes, you could certainly use the AttributeSplitter with a space as the delimter and test the second part in the tester.

 

To add the values to test against you have to read that from somwhere. Do you already have a list of possible values? For example lets say you have all the words in a text file. This file could be read in and merged into each feature with the FeatureMerger and then you could pick the list of attributes to test against. It would look something like this:

bilde

Thanks. The list of words will be supplied in a text file by the user for each situation, so this will work well, especially when I edit it to use regex as @dustin​ suggested below. I have been away from FME for a while so it will take me a bit of time to get the details figured out.


ronmak
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • December 28, 2021

I am getting familiar with regex and am wondering if I can test for multiple strings in one expression or not. The examples I gave above were over simplified. I may have 50+ strings to search for. In the example below, the first regex looks for either "SIB" or "IB" which may be followed by space or not and then maybe more characters. The next one looks for "IP" which may or may not be followed by a space and other characters, then "T"...

 

What is the best way to approach this?tester


kailinatsafe
Safer
Forum|alt.badge.img+19
ronmak wrote:

I am getting familiar with regex and am wondering if I can test for multiple strings in one expression or not. The examples I gave above were over simplified. I may have 50+ strings to search for. In the example below, the first regex looks for either "SIB" or "IB" which may be followed by space or not and then maybe more characters. The next one looks for "IP" which may or may not be followed by a space and other characters, then "T"...

 

What is the best way to approach this?tester

I did some searching, but this "OR"-type solution appears to be recommended by the majority! Hope this helps, Kailin.


Reply


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