Hi Team,
I tried to write dataweave for below outcome delimeter to separate '|' and ',' (Pipeline and comma) . But i can not get the proper split of delimeter separator as per the output. Could you please help me on this.
input:
[{ "a":"abc@com","b":"bb","c":"cc","d":"ddd"},{ "a":"abc@com","b":"bb","c":"cc","d":"ddd"},..]
Expected Output: text file
abc@com|bb,cc (we dont required the headers here)
My Dataweave:
%dw 1.0
%output application/csv separator='|'
%output application/csv encoding="UTF-8"
---
payload map [
$[4],
$[5],
$[7]
]
Note: can we write number of delimeters in field wise ??
Thank you!
@ramugudivada not sure if you can define multiple delimiters, may be you can try doing something like below.. define all possible separators as an array and use them
%dw 1.0
%output application/csv header=false
%var payload = [{
"a": "abc@com",
"b": "bb",
"c": "cd",
"d": "ddd"
}, {
"a": "abc@com",
"b": "bb",
"c": "cd",
"d": "ddd"
}]
%var separator = ["|",":",";"]
---
payload map using (val=$){
in : (1 to sizeOf ($)) map {
"val2" : (val[$$] ++ ((separator[$$]) default ""))
}.val2 joinBy ""
}
output:
abc@com|bb:cd;ddd
abc@com|bb:cd;ddd