Remove items of a list from a larger list

I have a list of desired sheets from an excel file that I want to create new sheets with. But some of those sheets exist in the model already. I have never been great with list logic and this is an operation I come across all the time and do some terrible hack fix for. Was hoping to learn this the right way.

How do I remove items in one list from another list? given that the one list may be longer than the other or the other way around. Thanks!

Hi,
use Set.ListDifference

1 Like

ah sweet node thanks!

So as a followup to this, I actually need to filter all 3 lists by this parameter. The issue is, my users are giving me a sheet list with sheets and names, and I need to remove the sheets that exist. But I cant count on the names they enter in the excel sheet to match the ones in project exactly, so I need to remove these same indicies I removed from the sheet number from the sheet names. What I am thinking is using the list.allindicesof node to find the indices of the items in list, and then using those to grab the items from the other list. The problem is not understanding the lacing and level issues here.

This is actually what I worked on but its not quite working. I need to check the indices of the larger list from this list.

You could build dictionaries from the Excel using the sheet numbers as keys. You can then use a ‘GetValueAtKey’ node using your values from ‘SetDifference’ as keys.

You can use indexes

3 Likes

This is exactly what I needed for my issue. Thanks!!

1 Like