Home > database >  Read and aggregate CSV files on Mule 4
Read and aggregate CSV files on Mule 4

Time:11-27

I have several CSV files with below format:

ID;NOTE;FISCYEAR;MONTH;CURRENCY;CURRENCY_2;NUMBERS;NUMBERS_2;CASH
177204930;"Something ""relevant"" date 01.03.07";2021;1;EUR;599;599000;599;"599,00 EUR"
175618258;"Address; 48ct xpto.";2021;1;EUR;1;1000;0.35;"0,35 EUR"

Where I must read and aggregate them into one payload to process (with batch) later. I must read ~50 files, with ~33MB each.

However, File List Operator don't have outputMimeType attribute, as in On New or Updated File, where I can configure in MIME Type tab the separator=; escape=" and streaming=true. I can't use this one as I can only read one file per time with it.

How can I solve this problem?

CodePudding user response:

Try using set variable to assign the payload of each file -which is a lazy stream to the contents- to a variable and in the same operation set the mimeType attribute.

<file:read>...
<foreach>
   <set-variable variableName="contents" value="#[payload]" mimeType="application/csv..." />
   <!-- process the file contents here as vars.contents -->
  • Related