Forum Discussion
Hi @gg433,
I’ve attached a pipeline to illustrate my thinking process here.
TwoRowsOnTopCSV_2020_06_25.slp (9.7 KB)
First I generate some test data in two JSON Generators. Then I combine their outputs with a Gate Snap. The Gate Snap outputs the documents it receives on input in arrays. It helps if you name the inputs of the Gate Snap, because then you can refer to the outputted arrays by name. Like I do, $top (for the aggregated documents we intend to put on top in the CSV file) and $bottom for the array containing the dummy data from the DB. In your case you would have the documents from the DB normally in the output of whichever snap you use, no need to transform it with a JSON Generator. Then in the Mapper Snap following, i have this expression:
$top.concat($bottom)
and I assign it to $, as a Target Path. Then I simply use a JSON Splitter to split the array, after that a CSV Formatter Snap, and so on.
One thing to note. In the top JSON Generator at the beginning, the field key for “&CID=555573” and “&SUBID=266690” is “id”. That, and another thing. In the CSV Formatter Snap have the “Use header” option unchecked.
Hope this helps.
BR,
Dimitri