Skip to main content

Hi !

I have a list named "coord" that contain 2 attributes "x" and "y". I would like to create an other attribute that concatate "x" and "y". For example :

line number 1 (one geometry) :

coord{0}.x = 1.25

coord{0}.y = 1.25

coord{1}.x = 2.25

coord{1}.y = 2.25

Résult :

coord{0}.x = 1.25

coord{0}.y = 1.25

coord{0}.all = 1.25;1.25

coord{1}.x = 2.25

coord{1}.y = 2.25

coord{1}.all = 2.25;2.25

Thanks for your help !

I was able to do it by using ListExploder and use Attribute Creator to create new attribute call combine and then put it back together using ListBuilder with Group Processing using ObjectID (or any unique number to that feature)

I compare the line after it put back together to make sure that element index actually go back to the correct place and it seem like it does (But definitely randomly check it in your case just to make sure)

 

Merge2att


Hi! Thanks for your answer. It work very well. Do you think it's possible to add a new attribute list using Python, to avoid geometry manipulation?


Hi! Thanks for your answer. It work very well. Do you think it's possible to add a new attribute list using Python, to avoid geometry manipulation?

Hi @alc33​ ,

PythonCaller with this script might help you.

class FeatureProcessor(object):
    def __init__(self):
        pass
        
    def input(self, feature: fmeobjects.FMEFeature):
        xs = feature.getAttribute('coord{}.x')
        ys = feature.getAttribute('coord{}.y')
        feature.setAttribute('coord{}.all',  '%s;%s' % (x, y) for x, y in zip(xs, ys)])
        self.pyoutput(feature)
 
    def has_support_for(self, support_type: int):
        return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
  
    def close(self):
        pass
 
    def process_group(self):
        pass

 

 


Hi @alc33​ ,

PythonCaller with this script might help you.

class FeatureProcessor(object):
    def __init__(self):
        pass
        
    def input(self, feature: fmeobjects.FMEFeature):
        xs = feature.getAttribute('coord{}.x')
        ys = feature.getAttribute('coord{}.y')
        feature.setAttribute('coord{}.all', o'%s;%s' % (x, y) for x, y in zip(xs, ys)])
        self.pyoutput(feature)
 
    def has_support_for(self, support_type: int):
        return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
  
    def close(self):
        pass
 
    def process_group(self):
        pass

 

 

@Takashi Iijima​ thanks for your answer !

I'm sorry but I have a termination message and I don't understand why?

I'm using FME 2020.2 and python 3.7+

Thank you.

 

image.png 


Hi @alc33​ ,

PythonCaller with this script might help you.

class FeatureProcessor(object):
    def __init__(self):
        pass
        
    def input(self, feature: fmeobjects.FMEFeature):
        xs = feature.getAttribute('coord{}.x')
        ys = feature.getAttribute('coord{}.y')
        feature.setAttribute('coord{}.all', o'%s;%s' % (x, y) for x, y in zip(xs, ys)])
        self.pyoutput(feature)
 
    def has_support_for(self, support_type: int):
        return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
  
    def close(self):
        pass
 
    def process_group(self):
        pass

 

 

I think the script should work in FME 2020 too.

Most likely you have not created xs and ys (lists of x values and y values) from "coord{}.x" and "coord{}.y".

Check if these two lines are correct. 

        xs = feature.getAttribute('coord{}.x')
        ys = feature.getAttribute('coord{}.y')

 


Hi @alc33​ ,

PythonCaller with this script might help you.

class FeatureProcessor(object):
    def __init__(self):
        pass
        
    def input(self, feature: fmeobjects.FMEFeature):
        xs = feature.getAttribute('coord{}.x')
        ys = feature.getAttribute('coord{}.y')
        feature.setAttribute('coord{}.all', o'%s;%s' % (x, y) for x, y in zip(xs, ys)])
        self.pyoutput(feature)
 
    def has_support_for(self, support_type: int):
        return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
  
    def close(self):
        pass
 
    def process_group(self):
        pass

 

 

You are right, the name of the list was different. It work very well! Thank you !


thank you very much @panda​ @Takashi Iijima​ !


Just a precision for the person that aren't used  to use pythoncaller (like me 🙂 ). Before the code above you have to write :

import fme

import fmeobjects

This 2 lines are in the transformer at his opening.

 

And then, to see the new attribute in the others transformers, you have to use AttribueExposer.


Reply