Skip to main content
Archived

Transformer for converting list/value pairs to attributes

Related products:Transformers
siennaatsafe
revesz
arnold_bijlsma
+1
  • siennaatsafe
    siennaatsafe
  • revesz
    revesz
  • dbaldacchino
  • jonathan
  • arnold_bijlsma
    arnold_bijlsma
  • rogerpettersen

I have what I think is a fairly simple use-case, but FME doesn't currently has the tools necessary to readily implement it. So this is a transformer suggestion for a ListAttributeMapper or something to that effect.

Basically I have a list like this:

_list{0}.class = 1
_list{1}.class = 2
_list{2}.class = 3
_list{3}.class = 5
_list{4}.class = 2
_list{5}.class = 1

I need to know how many of any given class there are with the feature. ListHistogrammer does this nicely:

_histo{0}.value = 1
_histo{0}.count = 2
_histo{1}.value = 2
_histo{1}.count = 2
_histo{2}.value = 3
_histo{2}.count = 1
_histo{3}.value = 5
_histo{3}.count = 1

My problem then is turning those into arbitrarily named attributes without a needlessly complex set of testers, let alone a PythonCaller.

I want my output feature to have attributes like these:

first_class = 2
other_thing = 2
third_item = 1
fourth_item = <missing>
final = 1

A kind of ListAttributeMapper would be one way to solve this. You'd point it at _histo{}.value, and for any given value in that field, tell it into what attribute name to to put the index equivalent value of _histo{}.count

Hopefully that's clear

This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

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