Skip to main content

Datatable-Deduplicating

Command Description

Remove duplicated lines in a datatable

Command Prototype

objDatatable = Datatable.DropDuplicatesDataTable(dtTable,aryColumns,strKeep)

Parameter Description

ParameterRequiredTypeDefaultDescription
dtTableTrueexpressionobjDatatableThe data table to be filtered
aryColumnsTrueexpression[]Columns that need to be deduplicated and retained
strKeepTrueenum"first"Columns that need to be deduplicated and retained

return

objDatatable,The variable used to save the output of the command.

Demo

aryData = [["a", 1], ["b", 2], ["c", 3], ["d", 1]] 
aryColumns = ["letter", "number"]
objDatatable = Datatable.BuildDataTable(aryData,aryColumns)
objDatatable = Datatable.DropDuplicatesDataTable(objDatatable,["number"],"last")

TracePrint(objDatatable)
/*
letter number
1 b 2
2 c 3
3 d 1
*/