Skip to main content

Hi FME wizards, I am trying to do a datum transformation on multiple files in a nested folder structure and save the outputs using an identical name and folder structure, but in a new directory location. I've created a replica of the folder structure using DOS commands and trying to replace the existing root folder with a new one.

 

I'm reading the source files in from a CSV, then creating a new 'outpath' attribute in AttributeManager using the StringReplacer to replace the source root level directory, e.g. the part in bold C:\\Project\\CurrentDatum\\Model\\file.ext with C:\\Project\\NewDatum\\Model\\file.ext. The source and destination directory are Published User Parameters and I use the following in the text editor: @ReplaceString(@Value(_dirpath),$(Source_dir),$(Destination_dir)). When I view this as a new attribute, the directory appears correct.

 

I've used similar logic in Python and it works great but not sure how to link it to my outputs in FME. This is my current workbench:

Workbench_SHP_onlyAny help would be greatly appreciated! Cheers, Angus

 

The setting you're looking for is called Fanout, it's a parameter on most Writers which will make it write the features to separate files, based on an attribute on each feature. You have derived that outpath already, so that'll be your Fanout expression to use. https://community.safe.com/s/article/fanout-1

 

You also don't need to create a folder before writing the files there, if the folder doesn't exist then FME will create it.


Thanks for your reply. I didn't know that FME created the folders if they don't exist so that saves me a step!

I do have a fanout expression on the model, but I'm still struggling to understand the concept. I've read that fanout can be applied to a dataset and feature. In my case, would I apply the outpath attribute as the fanout expression in the destination folder parameter? Or would it be a feature fanout in a writer?

 

I've since added a feature writer to my workbench following advice from another post. I've used my outpath attribute as the Dataset, which points to the folder that will contain the file, then I am using the fme_feature_type for the name, as this seems to persist for all features. But then I still need to provide an output destination folder, so not sure what to use there. Thanks for your help!


Yeah, that article is kinda weird for explaining it. Fanout is different for each writer, but for CSV you can control the filename and filepath (excel for example also has a sheet name you can control). Each feature needs attributes to set the filename, filepath, or both, and each feature with the same fanout attributes will write out to the same file. Using both, would look like this:

imagefme_feature_type can be your filename

filepath = C:\\Project\\NewDatum\\Model

The standard output folder parameter is still mandatory but won't be used, I imagine this is to handle the case where the fanout filepath isn't supplied, it still needs to write to somewhere.


Yeah, that article is kinda weird for explaining it. Fanout is different for each writer, but for CSV you can control the filename and filepath (excel for example also has a sheet name you can control). Each feature needs attributes to set the filename, filepath, or both, and each feature with the same fanout attributes will write out to the same file. Using both, would look like this:

imagefme_feature_type can be your filename

filepath = C:\\Project\\NewDatum\\Model

The standard output folder parameter is still mandatory but won't be used, I imagine this is to handle the case where the fanout filepath isn't supplied, it still needs to write to somewhere.

Thanks very much, this really helped.


Reply