I have csv file data i want to duplicate row according to duplicate ID and Member only take one row of one duplicate id and member column

condition:
Duplicate rows consider on Id and member columns
1 remove only those which product column is empty
2 if all product col value are empty of duplicate set then take only one and other remove
3 if duplicate rows has different product then take those rows also
Input:
![image|551x414](upload://k vWY3ZKO4aJteunUrHQKnBRC2xp.png)
yellow highlited rows want to delete
Expected Output:
![image|575x237](upload://s K7prRhZ6uIxCiSYw7NRKxC3Jxf.png)
@Anil_G

in general we can handle it by grouping the data and processing the members

@suyog79

Try this

Dt.AsEnumerable.GroupBy(function(x) x(0).ToString+x(1).ToString+x(5).ToString).Select(function(x) x.First).GroupBy(function(x) x(0).ToString+x(1).ToString).SelectMany(function(x) If(x.Count>1,x.Where(function(y) Not String.IsNullOrEmpty(y(5).ToString)),x)).CopyToDataTable

Hope this helps

Cheers

1 Like

Thanks @Anil_G Why getting this error
image

@suyog79

Changed the expression above …please take it again

made edit here

Cheers

Thanks @Anil_G
Could you help me with this

for above same condition
if Sample1 and Sample2 has data then i want to keep those rows also and if duplicate rows sample1 and sample2 column has duplicate value then only take one other row delete itInput:imageExpected Outpu:image

@suyog79

Try this

Dt.AsEnumerable.GroupBy(function(x) x(0).ToString+x(1).ToString+x(5).ToString+x(6).ToString+x(7).ToString).Select(function(x) x.First).GroupBy(function(x) x(0).ToString+x(1).ToString+x(5).ToString+x(6).ToString).SelectMany(function(x) If(x.Count>1,x.Where(function(y) Not String.IsNullOrEmpty(y(7).ToString)),x)).CopyToDataTable

cheers

Hi @Anil_G Why extra column add here

image
r

@suyog79

May be when reading there are extra columns…please check and filter them using filter datatable activity

cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.