How to delete by same row value?

Hi Hello…

How to delete by same row value?

“table1” keeps adding data.
In the figure, 782 has 3 rows and 779 has 4 rows.
Is there a way to keep only the first 782 row and 779 row?

delete_same_row_val.toe (3.6 KB)

Are you trying to do this just in DATs or is a bit of Python okay? One direction here would be to loop through the table to check if an entry already exists - if it does not, then add the new value to the table, otherwise ignore the new data.

‘table1’ is the bloptrack input and extracts only id, u , v using Python(Dat Execute).
I want the duplicate rows in ‘select4’ to be removed.
would you give us a Python sample?
thank you…

In your Execute DAT you can use a technique like this:

First create a list of only the id values:

ids = [cell.val for cell in op('table1').col(0)]

Next you’d check your new id against your list, and if the id already exists you could then choose to update the U, V vals, or pass

if newId in ids:
    # here we could update our vals
    op('table1')[newId, 1] = newUVal
    op('table1')[newId, 2] = newVVal
    
    # if you don't want to update the u, v vals, you could instead just use 
    # a pass statement 

else:
    # in this case the id does not yet exist
    # I'm guessing you're using appendRow() but don't know for sure
    # so this is where you might do any of that execution
1 Like

Let’s test the code you sent. Thank you.

sortDAT has a “Unique Output” parameter that can probably help you.

1 Like

Thank you Ivan. Works fine.