Dataweave get rid of empty lines when reading a file

1k Views Asked by At

I am processing a file where every other line is blank, how to get rid of these lines using dataweave or groovy? My payload now looks like this

enter image description here

my transformer which is parsing the lines is:

    %dw 1.0
    %output application/java
    ---
    payload map 
    {
        line: $[0]
    }

Thanks for the response

1

There are 1 best solutions below

0
On BEST ANSWER

Try the same dataweave with filtering the payload. Check if anything in the incoming payload is empty or null kind of thing which is causing the issue.

%dw 1.0
%output application/java
---
payload filter ($ !=null and $ !='')  map 
{
    line: $[0]
}