Question

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

  • 11 December 2021
  • 7 replies
  • 16 views

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

Badge +12

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

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?

Badge +12

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

Userlevel 3
Badge +26

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

 

image

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.

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

Userlevel 3
Badge +13

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