Skip to main content
I have an attribute value of the form: 1,2,3,4,...

 

 

I would like to split the attribute into separate values, using the comma as the delimiter.

 

 

I know I can do this with the AttributeSplitter but how do I get at the resultant parts? All of the examples that I've seen tell me to expose the attributes (right-click -> expose elements) which is fine if you know how many elements there are in the list but not if you dont know. I could have hundreds of elements...

 

 

The ListExploder doesn't work because the list doesn't have any attributes in it, just values.

 

 

I could write a Python script to do what I need but there must be an easier way?

 

Hi David,

 

I was doing exactly that and it wasn't working.

 

 

I deleted my transformers and replaced them and now it's working. Guess I must have had some odd setting in them originally...

 

 

Thanks for your reponse.

 

 

Nic

i have the same question, but i can't see the answer from David


i have the same question, but i can't see the answer from David

The ListExploder can be applied in many similar cases. Doesn't it satisfy your requirement?


I tried and was able to do this without Python:

Used the AttributeSplitter to create a list.

Explode the list into features using the ListExploder.

Then rename the listattribute using the AttributeRenamer with new name attr_@Value(_element_index).

This will result in attributes named attr_0, attr_1 etc.

The merge the features using the Aggregator grouping on every attribute except the former list attributes.

Then you will have the split attributes as attr_0, attr_1 etc on the feature.


If you want to do python it really is easy. Here is an example of one I did to split on a dash. Super simple:

you can prob make this work for how you want it or how you want to split it.

import fme

import fmeobjects


def processFeature(feature):



f_type = feature.getAttribute('F_TYP')

if f_type:

f_type_parts = f_type.split('-')

Height= f_type_parts[0]

Class= f_type_parts[-1]


feature.setAttribute("Height",Height)

feature.setAttribute("Class",Class)


Reply