Skip to main content
Question

Setting output file name at runtime based on an attribute value

  • November 13, 2018
  • 3 replies
  • 226 views

Forum|alt.badge.img

I have a workspace that reads multiple features from a CSV file, transforms them and then writes the results to a custom text format (using text_line_data).

I would like to set the name of the output file at run-time based on a 4 digit integer value read from a second input CSV file. For example, if the integer is 2934 then the relevant attribute is set to OUTPUT_FILENAME=output_2934.txt

However, I am getting in a mess trying to configure the output text writer. If I fanout on OUTPUT_FILENAME, I get two output files (rather than the desired single file) when I run the workspace. The files produced are output_2934.txt (with no content) and output_.txt (with correct content). If I don't set the fanout, I can't see how to configure OUTPUT_FILENAME.

Is my approach fundamentally flawed? Any help much appreciated.

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.

3 replies

ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • November 13, 2018

To fanout by attribute all the features you are writing must have that attribute with the relevant value. If this is coming from a second writer you need to ensure you are adding it as an attribute to the features you are writing

e.g.


takashi
Celebrity
  • November 13, 2018

All the features should have an identical value (2934 in the example) in the OUTPUT_FILENAME attribute if you intend to write them into a file named "output_2934.txt".

Check if the OUTPUT_FILENAME in every feature stores "2934", using FME Data Inspector. The Workbench menu: Writers > Redirect to FME Data Inspector option is useful to send all features to FME Data Inspector instead of the writer.


Forum|alt.badge.img
  • Author
  • November 14, 2018

Thank-you both @takashi and @egomm! This now works like a charm. I didn't appreciate that every feature (1000's) needed to have the same value of the OUTPUT_FILENAME attribute (a single value). The FeatureMerger did the trick.