Skip to main content

Hi all

 

I have a list like

 

somelist{0}.val = 'apple'

somelist{1}.val = 'donut'

somelist{2}.val = 'aardvark'

somelist{3}.val = 'apple'

somelist{4}.val = 'aardvark'

somelist{5}.val = 'apple'

 

 

the list histogrammer transforms it into

 

_histogram{0}.value = 'apple'

_histogram{0}.count = 3

_histogram{1}.value = 'aardvark'

_histogram{1}.count = 2

_histogram{2}.value = 'donut'

_histogram{2}.count = 1

 

 

now I want this information as attribute pairs like

 

attribute_name    attribute_value

apple                   3

aardvark              2

donut                   1

 

any Ideas how to do this in FME without fancy scripting or looping are much appreciated!

 

I know there is the AttributeCreator

 

 

but the created attributes need an AttributeExposer to make them visible in folowing transformer or writers.
Since I don’t know all the possible values like apple, donut, … in advance, or there migth be too much, I’m stuck...


Hi ​@ziur You could skip the histogramer by Grouping the list on the attribute then using the ListElementCounter
Hope that helps!
 

 


thanks crutledge

your example still does not have the names as new attributes

 

let me be more clear. the source data format looks like

and the target shoul look like this

I don’t know the NAMEs in my data, they can change every day.


Ah. 2d table. This is on my list-o-things to get better at. I am working through this using: Transpose a Table Using FME – FME Support Center


Okay I think I got a version working. Using 2 aggregators we get to a table with box as rows and attributes as columns. Not perfect but I hope it gets you going in the right direction.

 


Thanks ​@crutledge for your input.

the result looks as desired. one point is still not resolved: you typed in the attribute names in the AttributeExposer:

Any chance to do this dynamically depending on the data?


Thanks ​@crutledge for your input.

the result looks as desired. one point is still not resolved: you typed in the attribute names in the AttributeExposer:

Any chance to do this dynamically depending on the data?

If your workspace is truly dynamic, there is no need to expose the attributes.

If you need to expose attributes for subsequent processing, your workspace is no longer dynamic

 

This is how I would transpose your data

 


Hi ​@ebygomm 

thats true, thank you. I was at this point in my second post of this thread, where I used the AttributeCreator in the same manner as you.

It leaves me with the problems to pass those unexposed attributes to the writer…

I wish the AttibuteExposer would work like this  😁

 


Attributes don’t need to be exposed to be passed to the writer, as soon as they are exposed the workspace is no longer dynamic.

 


Okay. This one might work. I don’t know why but my brain always melts with exploders and lists and all the fun stuff so I am trying to get better at it. With ​@ebygomm ‘s suggestion I put this one together. Hopefully this works for you. I added a schema scanner b/c I just couldn’t get it to spit out the unexposed attributes no matter how dynamically i danced :D
Hopefully this helps.


...as soon as they are exposed the workspace is no longer dynamic.

 

with the automatic Attribute Definition in the writer it would be dynamic enough for me :-)

the attributes wouldn’t have to be defined anywhere in the workspace

but unexposed Attributes are not written…

 

 

Anyway with @crutledges example I’m happy. Althoug he says it would not spit out the not exposed attributes - funny enoug it works for me!? :-) 

 

Thanks both of you for your thoughts and ideas!

Cheers


Glad it got you working ​@ziur . Did the attributes come out for you using the #2 writer (below)? i.e. you did not have to use the schemascanner? Just curious. Always learning.
 

 


@crutledge Yes, number 2 is good. I suppose it is your writer with the option <@value...>

this produces the columns wanted - among others I happily ignored.