i have json array which have not fix length, for example
[
{
a: 1
},
{
a: 1,
b: 2
},
{
a: 1,
c: 3
},
{
a: 1,
b: 2,
d: 4,
f: 6
}
]
I need to transform them into CSV file with header. Below script only return header of the first line, not all columns. May I know how to operate?
%dw 2.0
output application/csv separator = " ", escape = "", header = true, encoding="UTF-8"
---
payload
i expect result like so
Another solution is to use my csv-module (https://github.com/rbutenuth/csv-module). There you specify the headers in the configuration and don't take them from the input data.
Works even when you input data is missing one column in the whole dataset. And provides meta data for easier mapping with DataWeave.