Remove duplicate rows based on a value from a single data column


#1

I want to remove duplicate rows from a datatable if a particular column1 value is duplicate in other rows.

dtOutput=dtOutput.DefaultView.ToTable(True,“column1”)

when I try this it removes all the columns as well, but I need the rest of the columns.


#2

@banerjeerules check attached file i hope its useful

RemoveDuplicatesInSingleColumn.zip (12.8 KB)


#3

You can try filter data activity if feasible


#4

Thanks this works in getting the datatable sorted, but when I write the data table on the same excel sheet the remaining rows stays back… if I write on a different sheet it is fine. Can you tell me how can I write on the same sheet from where I am picking it up.


#5

You need to first clear the Excel sheet. As read range will just overwrite the already present rows. Use hot keys to clear the excel sheet first then use a write range.

Below are the steps

Use Excel Application scope
Select Range ->Menstion the sheet name and Range->“A1”
use Send hot key -> ctrl+A (Provide selector to the excel sheet)
use Send hot key -> delete
use Send hot key -> ctrl+s
Then use Write Range with your filtered DataTable.


#6

@indra using your code I get the following error Assign : Unable to cast object of type ‘System.Double’ to type ‘System.String’. Can you help


#7

@banerjeerules Do you change code in assign activity ?


#8

I changed the whole excel to text format now it works