Author: Peeyush Kandoi

Today I am writing this blog to share my knowledge on a very basic scenario where we need to process a TSV (Tab-separated value) file in Mulesoft specifically in Mule 4. There can be multiple ways to do that. I will share two of them, we will see what issue I faced in 1st and then how the 2nd way works exactly fine for me.

Below is the sample TSV file:

Now, let’s consider this file is placed in AWS S3 bucket and we are fetching this file from there using GetObject connector in Mule 4 as shown below:

Now comes the 1st way, where what we can do is, we can set below configurations to fetch the TSV file and convert it into CSV right there within this connector (we will get the same configuration set up in all other connectors as well):

This will appear in the Message Flow as below

As we can see, separator value which works for TSV file in Mule 4 is – “	”. If you run this code, it will work perfectly fine and we will get data in CSV Format

Now, the problem which I faced with this approach is that the separator value is becoming null intermittently in local as well as in the deployed code. I tried with saving the field-value in property file also, but no luck :(. This is still an open question about this unusual behavior but since I couldn’t have much time to explore more (tight project deadlines you know 😉 ), I came up with 2nd solution which works exactly fine for me.

Here comes the 2nd way:

Now, we will fetch the file in TSV format and will not use the separator property as shown below

We will do the transformation in Transform Message next to this connector where we will be using the split function to convert the tabs into CSV format and then will do the mapping stuff as shown below

Required Output:

Leave a Comment

You must be logged in to post a comment.