简体   繁体   中英

Using of Distinct by in dataweave for CSV output in mulesoft

I am using data weave connector in my mule flow ..

Details:- From input side I am getting collection of array and I want to convert into CSV and write into the file.

But for particular column I am getting duplicates value and I want to remove them through data weaver.But when I am putting distinct by in front of that particular column ...code is not Woking and my getting below exception.

"Cannot coerce a :string to a :array"

Below is the mapping I am doing from output side.

dw 1.0
%output application/csv
---
payload map ((value, index) -> {
   A1: $.A1 distinctBy $ ,
   B1 $.B1,
   C1: $.C1,
   D1: $.D1,
   E1: $.E1,
 F1: $.F1

))

Guys please let me know how to use distinct by for "A1 Column" or any trick to remove duplicates value for particular column inside the data weave even i have tried group by but same syntax error is coming.. :(

Cheers, Stevin

请在MuleSoft论坛上找到相同的解决方案

Use distinctBy $.A1 outside the map

dw 1.0
%output application/csv
---
(payload map ((value, index) -> {
 A1: $.A1,
 B1 $.B1,
 C1: $.C1,
 D1: $.D1,
 E1: $.E1,
 F1: $.F1
 )) distinctBy $.A1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM