Skip to main content

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.

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.


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.


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.


Reply