Skip to main content
Question

Testing for multiple input files

  • December 5, 2012
  • 2 replies
  • 105 views

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
What is the best way to test for multiple input files on a single reader?

 

 

I have a workflow where the input is one or more files and the output filename will be based on the input filename if there is only one file but a constant if there are multiple files.

 

 

Joanna

2 replies

Forum|alt.badge.img+4
  • December 5, 2012
I'm not sure about the 'best way' but two possibilities come to mind:
  • Use an Aggregator and group by fme_dataset or fme_basename. Hook in a Counter to count how many files there are. Use a VariableSetter to set the Count as a Global parameter and then a StatisticsCalculator to grab the max count . A Tester could then use the count to determine whether a static or dynamic output filename can be used. Disadvantage of this approach is of course the Group-based transformers and requirement of multiple streams of data (as Aggregator of course aggregates...). This disadvantage could be offset by having a separate reader using the Max Features to Read set as 1 and sharing the Source via a shared Published Parameter.
  • Grab the Source published parameter. Use RegEx or maybe an AttributeSplitter and/or Tester to determine whether the Source contains a * sign (which 'could' mean multiple files) or a space separating two sets of double quote encapsulted filepaths. 
There's likely a much more simple way out there but I'd personally probably go for Option 2 if I had to have it done in the next 10mins.

 


sigtill
Supporter
Forum|alt.badge.img+24
  • Supporter
  • December 6, 2012
I would use a File and Path Reader to get the filenames in the inputdirectory.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings