Hi!
I am trying to write some aggregated data to a file using the FlatFileWriter and then add all records as details to the same file using a second FlatFileWritter having a higher phase with the setting to append.
I have set the property “With field names“ to true on both FlatFileWritters. But the result is not as expected. Only the first FlatFileWriter added the field names, the second one does not.
I have tried using different settings to see if I could get it working but it does not seem to work. If append is set to false and the first data will be overwritten, the fieldnames from the second set of records are in the file.
Could it be that Clover will ignore the property “With field names“ is true when append is also set to true (The assumption that you would never want to add the fieldnames when appending to a file)?
Edit: I tried the same with the SpreadsheetWritter and there the fieldnames are not written when appending to the file.
I’m using CloverDX Designer 7.3.
Thanks in advance!
Michel
Hi Michel,
This can be achieved, but unfortunately in a bit more complicated way (albeit more flexible). See the attached project which demonstrate the solution.
Description of the graph/solution
Essentially, you need to switch your writers to actually write to output port in a streaming way. What it does is that instead of writing to specific file, writer starts chopping the output into chunks and sending them through output port.
Your output port has to have one field defined (string) with no delimiters (both for record and for that field). You set up exactly the same way to your second writer.
Then you just use Concatenate component to first take everything from first writer and then all from second (you could have third, fourth, etc…).
Then important thing is Filter component (you will see it in the example). It filters out records with that one field being equal to NULL. That NULL is used by the writer to signal that it finished sending its output, and we don’t need it in this particular case. Then finally you send everything to FlatFileWriter (3rd) and save to disk.
I hope this helps.
David
ConcatFilesExample.zip (9 KB)
Thanks David, I will check it out!