cancel
Showing results for 
Search instead for 
Did you mean: 

Creating CSV file with Header in first column

SL12345
New Contributor III

Hi SnapLogic experts,

i have question, if described example could be done via snaplogic. Output should be .csv file with structure:


Column1
Column2
Column3
Column4
Column1Values,Column2Values,Column3Values,Column4Values


"Headers" should be in first column of target file and after last header (Column4) csv should continue with values of specific headers but in separated columns.

I can do it with 4 columns, but my real example is more than 500 headers, and there is problem with string length and my headers are trimmed.

So what will be best approach to do it via snaplogic? Is it even possible to do it via one CSV parser, due to delimiter rules or so? thank you

3 REPLIES 3

alchemiz
Contributor III

Hi @SL12345 ,

How are you receiving your inputs? Is the input a list or object?
Assumption: input object are received as streaming object

alchemiz_1-1692729633553.png

Use a Gate snap to put all received "input" object into an array, once in an array you can use the below expression to pivot the input as header name and value

$inputs.filter((a,b,c)=> b < ($inputs.length - 1)).map(i=> i['input']).toObject((v,i)=> v, (v,i)=> $inputs[$inputs.length - 1]['input'].split(',')[i])

Is this what you're trying to achive?

alchemiz_0-1692729459822.png

 

 

hi

Hi @alchemiz,

Can you please provide pipeline to download. I didn't get what to use inside pivot snap.