Skip to main content
Solved

Value mapping but by number of items

  • August 14, 2018
  • 1 reply
  • 4 views

Forum|alt.badge.img

Hi,

Bit of on odd one i cannot work out. I have some tabular data e.g.

203040325

The headers are 20,30,40 with values 3,2,5.

Is there a simple oway to end up with

20304020,20,2030,3040,40,40,40,40

Thanks

Best answer by david_r

Try the following in a PythonCaller:

import fmeobjects

def multiply(feature):
    attr_names = feature.getAllAttributeNames()
    for attr in attr_names:
        if attr.isdigit():
            value = int(feature.getAttribute(attr))
            result = ','.join([attr] * value)
            feature.setAttribute(attr, result)
View original
Did this help you find an answer to your question?

1 reply

david_r
Celebrity
  • Best Answer
  • August 14, 2018

Try the following in a PythonCaller:

import fmeobjects

def multiply(feature):
    attr_names = feature.getAllAttributeNames()
    for attr in attr_names:
        if attr.isdigit():
            value = int(feature.getAttribute(attr))
            result = ','.join([attr] * value)
            feature.setAttribute(attr, result)

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