Compare two rows in the same Datatable

Hello RPA lovers,

How to compare two consecutive rows of the same Datatable and if they are the same remove the second one?
I don’t have names assigned to datatable headers
I hope some experts can help me =D

@Asghany You can use “Remove Duplicates Range” activity to remove all the duplicates in the Data Table. You can use Remove Duplicates too.

Hi @Asghany

Use an if condition

Use remove data row activity


1 Like

@Asghany Remove Duplicae Rows From Datatable and write the new DT to new Excel File. :sweat_smile:

@supermanPunch @MartianxSpace @AshwinS2

Thank you for your quick answers.
Remove duplicates will not work, since I want to remove accordingly to one column specification and not the all row.
Row(“columnname”).ToString.equals(row(“columnname”) will also not work because I don’t have headers names on my columns

@Asghany IF you don’t have header name then you can use row(0).ToString

You are talking about this right? Row(“columnname”).ToString.equals(row(“columnname”)

But row value will be the same.
I want to compare the row(0) wit row+1(0)

@Asghany If No Headers are available , then when you read the File , Uncheck Add Headers Option, in that way by default you will get ‘Column0’,‘Column1’,… as the headers

1 Like

Like this?
dt_Sorted_2.AsEnumerable().GroupBy(Function(a) a.Field(Of String)(‘Column1’)).Select(Function(b) b.First).CopyToDataTable()

@Asghany Sorry Double Quotes “Column0” :sweat_smile:

1 Like

:sweat_smile: Yeah, my bad…I inserted " " later.

This error pops up

@Asghany Seems Like there are no rows after you GroupBy :thinking:

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