cancel
Showing results for 
Search instead for 
Did you mean: 

Merge binaries into single document

dwhansen-cbg
Contributor

I have 3 binaries as three documents. Is it possible to merge the three binaries into a single document and write it to a file?

16 REPLIES 16

dwhansen-cbg
Contributor

I’ll give this a shot. My concern is that the header, detail, and trailer records all have different numbers of columns. 2 - 40ish - 3

dwhansen-cbg
Contributor

So close. I got close to this point last week. What happens when you have different numbers of columns when using a CSV formatter, it adds additional columns to the front of each detail and trailer row. The CSV formatter doesn’t like different numbers of columns

What are the contents of the header and trailer? Are they valid CSV rows or plain text?

dwhansen-cbg
Contributor

The header is 2 columns (no actual header) - record_type and description. The trailer is 3 columns (no actual header) - record_type, number of detail rows, and end of file field. There can be N number of detail records. They all start with record_type column and then have ~40 columns. The header and trailer rows are also pipe-delimited.

dwhansen-cbg
Contributor

The pipeline you shared above gave me an idea. I tested it and it looks like it will work for what I need to do, although I still need to figure out how to get the total number of detail rows to put in the trailer.

Get your header/details/trailer → CSV format however you need them → Bin2Doc → Join Merge → Mapper (Base64.decode($content).concat(Base64.decode($detail_content), Base64.decode($trailer_content))) → DocToBin → File Writer

image

I don’t believe that this is the most efficient way of accomplishing this task but it looks like it will work. What do you think @tstack?