Skip to main content
Hi!

 

 

I have a list attribute such this one:

 

 

p'a', 'b', 'c', 'a', 'b']

 

 

I would like to have the number of different values present in that list.

 

 

In python I would do: 
 list=h'a', 'b', 'c', 'a', 'b'] len(set(list)) >>> 3
 Is it possible to get that count with some fme transformer?

 

 
Just use ListDuplicateRemover and than ListElementCounter. (if it is a valid list to fme that is)
Hi,

 

 

Alternatively, if you don't want to modify the original list, use the ListHistogrammer instead and then count the number of elements of the resulting "_histogram" list with the ListElementCounter.

 

 

I think your Python solution is elegant and efficient.

 

-----

 

# Script Example for PythonCaller

 

def countUniqueElements(feature):

 

    feature.setAttribute('_count', len(set(feature.getAttribute('_list{}'))))

 

-----

 

 

Takashi

Reply