Skip to main content
Solved

loose match

  • May 18, 2015
  • 8 replies
  • 15 views

Forum|alt.badge.img
Good afternoon,

 

 

I have this issue come up now and again and I'd like to be able to solve it. But I frequently get excel spreadsheets that neet to be mached to a Point Layer in SDE. Normally I take the geometry of the SDE layer and keep the attributes of the spreadsheet. I normally use the FeatureMerger transformer. My problem is sometimes the number I use to match on is sometimes odd in the spreadsheet such as having trailing zeros or just any number of extra characters (normally 8000+ rows). So question being is there a way to do a "Loose match" on the fields to come up with a match? Thanks!

Best answer by takashi

The StringFormatter might help you.

 

Format String: -014s

 

 

The format string means:

 

- the minimum number of characters should be 14

 

- add trailing zeros if the original number of characters is less than 14. 

 

See the help on the StringFormatter to learn more about the fomat string.

 

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.

8 replies

takashi
Celebrity
  • May 19, 2015
Hi,

 

 

If you need to ignore all trailing zeros and non-digit characters in the number coming from the spreadsheet, one possible way is to remove them using a StringReplacer with this setting beforehand.

 

-----

 

Test to Match: (.*[1-9])([^1-9]*)$

 

Replacement Text: \\1

 

Use Regular Expressions: yes

 

 

But it doesn't work for a case where the number coming from the SDE table ends with "0", e.g. "120". If there could be such a case, you will have to think of other approaches.

 

 

Takashi

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 19, 2015
..i bet he meant leading zero's  

Forum|alt.badge.img
  • Author
  • May 19, 2015
Thanks for the replies. In some instances it would be leading. Since this does not seem to work on SDE what would be the Regex for adding 4 zeros to a 10 digit number so as to modify the excel side? 

takashi
Celebrity
  • May 19, 2015
Could you please show us some examples of the original string and the preferable result after modifying?

Forum|alt.badge.img
  • Author
  • May 19, 2015
Yes, in this case nearly all the records are 9 to 10 characters long. 3507725552 -> 35077255520000 or 307170548 -> 30717054800000. 

takashi
Celebrity
  • Best Answer
  • May 19, 2015
The StringFormatter might help you.

 

Format String: -014s

 

 

The format string means:

 

- the minimum number of characters should be 14

 

- add trailing zeros if the original number of characters is less than 14. 

 

See the help on the StringFormatter to learn more about the fomat string.

 


Forum|alt.badge.img
  • Author
  • May 19, 2015
Thankyou, I can't believe I didn't see this when looking through the transformers. But makes perfect sense. 

takashi
Celebrity
  • May 19, 2015
A little bit advanced technique.

 

You can also set this expression directly to the "Join On" parameter of the FeatureMerger.

 

-----

 

@Format(%-014s,@Value(the_number_attribute_name))

 

-----

 

 

@Format is one of the FME String Functions, the behavior is almost equivalent to the StringFormatter transformer.

 

String Functions (http://docs.safe.com/fme/html/FME_Transformers/FME_Transformers.htm#transformer_parameters/StringFunctions.htm)

 

 

FYI