Understanding CSV Files: Creation and Usage | MuleSoft Guide

What is CSV File

 Commas are used to separate each value in a CSV file, which is a plain text file that contains data in a table-structured fashion. Comma Separated Values is what CSV stands for. Spreadsheets, databases, and online applications are just a few of the applications that frequently communicate data via CSV files.  

How To Create CSV File Manually

 You can use a spreadsheet tool such as Google Sheets, Microsoft Excel, or OpenOffice Calc to produce a CSV file and then store your data in that format. A text editor such as Notepad or TextEdit can also be used to manually enter your data, with commas used to separate each number and a new line for each row.

NOTE: It appears that we are unable to save all of the worksheets in a single CSV file using Microsoft Spreadsheet. Within the CSV file, it stores a single worksheet.  

 How to Use MuleSoft to Create a CSV File with Several Worksheets  

 In order to solve the aforementioned problem, I put in place a Mule API that can produce several spreadsheets within a single CSV file. To accomplish this, we must adhere to the structure below in order to create many tabs:

The following format should be used for the payload structure:  

Accepted Format:

{  SheetName1: ArrayOfData,  SheetName2: ArrayOfData}

We should use the following output format and characteristics in order to allow many sheets in a single CSV file: 

output application/xlsx header=true 

Example: 

%dw 2.0output application/xlsx  header=true---{  Sheet1: [    {      Id: 12312,      Name: "George Wong"    },    {      Id: 45688,      Name: "Lucas Khan"    }  ],  Sheet2: [    {      Id: 123,      Name: "George"    },    {      Id: 456,      Name: "Lucas"    }  ]}

You must write the script mentioned above in the file write connector located under the content section.  

Example:

%dw 2.0output application/xlsx  header=true---payload

NOTE: In this instance, the payload needs to be in the accepted format listed below.   

]]>
Post a Comment (0)
Previous Post Next Post