Skip to main content
Archived

Transformer for converting list/value pairs to attributes

Related products:Transformers
  • March 27, 2017
  • 0 replies
  • 24 views

Forum|alt.badge.img

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 an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, 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.