Solved

How to log the output of transformers

  • 28 July 2021
  • 1 reply
  • 2 views

Badge +1

I have 3 Transformers (StatisticsCalculator) at the end of my workbench. They all sum up some values. As the output of the working process I would like to create a log file or text file that show the results of the Transformers like

Humus: XXX m3

Volume 1 : XXX m3

Volume 2: XXX m3

Values are the output of StatisticsCalculator. I used Text File Writer where I collected all info in text_line_data. However, the output does not look how I imagined. It repeats it 3 times https://i.imgur.com/2OpR3lg.png

Any idea how I can avoid repetition?

 

https://i.imgur.com/9ejOMzh.png

https://i.imgur.com/IrG2xcL.png

icon

Best answer by chrisatsafe 28 July 2021, 20:36

View original

1 reply

Badge +2

Hi @jugoslaviaa​ ,

 

There are a few ways you could deal with but, I would use an Aggregator (to aggregate all three features into a single feature), then set the text_line_data value as:

Humus: @Value(attribute1) m3
 
Volume 1 : @Value(attribute2) m3
 
Volume 2: @Value(attribute3) m3

This works because you are aggregating three streams and all three have separate attribute values so you aren't overwriting conflicting attribute values when using the Merge Incoming Attributes Accumulation Mode in the Aggregator. 

 

A couple of things to keep in mind

  1. When you are setting attribute values, when the @value(<attributename>) is red, it means that attribute is not present on features connected to that stream. Another queue is the attribute name should show up under the FME Feature Attributes Drop down in the text editor. 
  2. Every feature sent to the Text File Writer will write the value of the text_line_data attribute to the file (this is why it's written three times in your output) - assuming each AttributeManager contains the value you have shown in the screenshot .

 

Have a look at the attached example as it should help :) 

 

There are a number of other ways you could accomplish this like using a Sorter and only sending individual lines to the text file writer (i.e. Humus: @Value(attribute1) m3) from each stream but personally I like using the Aggregator approach when I values from different streams don't have the same attribute name. 

Reply