cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Consolidate Header file and Data file

darshthakkar
Valued Contributor

Hi Team,

Iโ€™m having 2 separate excel files; one containing the headers ONLY and the other one having the actual data. How can I MERGE these 2 files into a single entity so that further transformations can be applied and eventually sent to downstream system?

Sharing some screenshots of the sample data and solution achieved thus far:

(1) Payload (it will always have the data and NOT the headers thus unchecked the option of โ€œcontains headersโ€ in excel parser)
image

(2) Header File (it will always have the header details ONLY, again unchecked the option of โ€œcontains headersโ€ in excel parser)
image

Used a UNION snap and got the below output:
image

Output required:
image

Thanking in advance for your time and assistance.

Regards,
Darsh

1 ACCEPTED SOLUTION

Hello @darshthakkar,

If Iโ€™m understanding correctly you can achieve it by using the sl.zipObject function.

Before that you have to turn the keys and the values in two separate arrays.

image

In the router we are separating the keys (the first object) and the values by using the snap.in.totalCount function.
Then, we append the keys to each object values and finally we zip them together.

Please refer to the attached pipeline below:
sl-comm-excel-headers_2023_06_12.slp (9.5 KB)

Let me know if this helps.

Regards,
Aleksandar.

View solution in original post

9 REPLIES 9

darshthakkar
Valued Contributor

I used a UNION snap to merge the header and data file, after that I used the snaps you suggested from Router and below is the output:

image

image

image

I have intentionally used a file writer at the end because the output preview is misleading many a times and this time it was no different. It took the actual header as HEADERS in output preview but as soon as the pipeline was executed, the headers changed and the output changed eventually.

darshthakkar
Valued Contributor

Removed the Union and Router snaps if we are getting separate files from upstream and the required output can be achieved.

darshthakkar
Valued Contributor

Utilizing the solution provided by @AleksandarAngelevski with a minor tweak (of removing Router snap) as below:

image

Thank you @AleksandarAngelevski for your time and assistance on this one, it is much appreciated.
Closing this thread now.

Regards,
Darsh

Glad to be of help Darsh! ๐Ÿ˜€

Thank you as always ๐Ÿ˜Š