Skip to main content
Question

How to modify text attributes from SHP


Forum|alt.badge.img

Hello,

I have text attributes of dimensions - such as 500/90 , 800/460, 30/90 etc. In a result I need to get the largest dimension value and delete the rest. For example - get the value 800 (and delete /460) or get 90 (and delete 30/ ).

Any ideas, how to manage this?

6 replies

david_r
Celebrity
  • February 27, 2018

Here's one way to do it:

  1. AttributeSplitter on "/", this will create a list with alle the dimension values
  2. ListSorter "numeric descending" on the list
  3. ListIndexer to extract list item 0, which will contain the largest value
  4. AttributeRemover to remove the temporary list

jneujens
Forum|alt.badge.img
  • February 27, 2018

Use regular expressions in a StringSearcher.

For the counter: \\d+(?=\\/)

For denominator: (?<=\\/)\\d+


takashi
Influencer
  • February 27, 2018

I would use the ExpressionEvaluator with this expression after splitting the dimension into two parts with the AttributeSplitter.

@max(@Value(_list{0}),@Value(_list{1}))

david_r
Celebrity
  • February 27, 2018
takashi wrote:

I would use the ExpressionEvaluator with this expression after splitting the dimension into two parts with the AttributeSplitter.

@max(@Value(_list{0}),@Value(_list{1}))
If the list never contains more than two items, this is a great solution.

takashi
Influencer
  • February 27, 2018
takashi wrote:

I would use the ExpressionEvaluator with this expression after splitting the dimension into two parts with the AttributeSplitter.

@max(@Value(_list{0}),@Value(_list{1}))
Yes, the solution can be applied only if the text contains just two parts.

 

Just an experiment. The TclCaller with this expression can be applied to any number of dimensions, also no need to AttributeSplitter.

 

expr max([regsub -all / [FME_GetAttribute text] ,])

 


Forum|alt.badge.img
  • Author
  • February 27, 2018

I tried all three methods:

 

For me Mr. takashi`s suggested method works perfect as well as Mr.david_r`s method.

For this time I used Mr. takashi `s method, but I also made a transformation, using Mr.

david_r`s method for more complicated cases.

 

About jneujens method - maybe I do something wrong, but following by steps in Your comment, I`ve got one new column with a value before and other new column with value after the "/" but not the value of the largest one, so I must compare them.

Anyway - Thanks to all!


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