Skip to main content
Suwandi Cahyadi ha preguntado en #MuleSoft

Hi, 

 

I am learning Dataweave with the dataweave playground available online. 

There is a question that I want to ask and I include the screenshot below to better explain this: 

 

Understanding Dataweave for CSV input

 

So, the left hand side, the data is 2 lines of CSV format: 

0088|12345 

0088|12345 

 

In the middle, on line 14, I try to splitBy the payload by '\n' 

 

In the right hand side, there is an error that I believe basically says I cannot split on an array argument  

 

[{"0088|12345": "0088|12345"}]

 

My question is, how the 2 lines of the CSV input can become Array format that if I interpret, it looks like a json object with field "0088|12345" (1st line) having the value of "0088|12345" (2nd line)? 

 

Thank you 

 

 

 

#MuleSoft

1 respuesta
  1. 19 sept 2025, 21:15

    Use below: 

     

    %dw 2.0//Author Manish Yadavoutput application/jsoninput payload application/csvvar defaultValues = {    TABNAM: "EDI_DC40",    MANDT: "800",    IDOCTYP: "PORDCR02",    MESTYP: "PORDCH",    NO_MORE: "X"}var groupedData = (write(payload, "csv")) splitBy "\n"---groupedData joinBy " - "//for output application/xml use like (root: groupedData joinBy " - ")

     

     

    Use below: %dw 2.

     

     

0/9000