Cull Same Items in list

Im looking to create a Boolean list of if items in a list are uniqe. The Dictionary.ByKeysValues doesn’t allow duplicate keys so I want to delete duplicates but I need to delete those values in other lists so their index continues to line up.

You’ll have to show us your data set and what you’re looking to do exactly. It sounds like you just need List.UniqueItems and some list management but it’s impossible to say exactly without an example.

The 214.1 in the first list is repeated. I used List.UniqueItems but ill need to change the bottom list in the same way.

I tried == but after 214.1 all of the items are false

You need to use the unique list with the dictionary. You also need to use list levels with list contains, otherwise it’s considering the full list as the “item” input.



Its difficult because the list does contain 214.1 I just don’t want two

This is why you need to explain exactly what it is you’re after. Draw up an example of what you want the outcome to be. If you’re making a dictionary then you need unique key,value pairs. What do you want to do with your original list that requires a dictionary or non-unique values?

Yeah sorry.

So its a script that takes an excel file and matches the data in excel with the room numbers for quick colored plans. I index the room number column and the department column then make a dictionary with the room number as the key and department as value. Sometimes on the excel file need to have duplicates of the room number but duplicates don’t work as keys in the dictionary. When I use List.UniqueItems it deletes the duplicated room number but the department list stays the same so the list order no longer matches the right room number.

The excel file is has multiple buildings so Ive been using boolean lists to filter the information down to just what I want. There is probably a better way to do this(Im new to dynamo).

I want a Boolean list of what items the List.UniqueItems took out so I can filter the department list the same way.

Bingo!
In the achilab pack there is the duplicateItemIndicies node that returns a index of the duplicates

Index will work. Another option would be to group both columns by room name and then take the first item from each group. This would ensure one value per room name and could be done for both rooms and departments in parallel.

1 Like