Filter one list using another list

I know this is a variant of some other questions, but I’m new to this, and haven’t figured it out yet. I have list (imported from excel) of sheets I need to create - with sub-lists for sheet number, sheet name, and three custom parameters we need. From that, I can create the sheets by following any of several posted examples. But my script stops as soon as it gets to a sheet that already exists, so I want to filter my list of desired sheets to remove sheets that already exist. Creating the list of sheets that exist is also easy enough. But what I have not yet figured out is how to remove from the Existing Sheets from the Desired Sheets.

CP

Hi CP,

I’m new to this, too, but I find that trying to help others helps me learn. So here’s my suggestion: could you try the “Strings.SearchListForString” node? Alternately, perhaps a simple “==” node with a “List.FilterByBoolMask”. The only thing I don’t know is if you have to iterate through, will these nodes work? I don’t know.

Perhaps these will help as a start. If you post a screenshot of your definition and the Excel spreadsheet, I might have time to give it a shot!

Here’s the screenshot:

As a new user, I am apparently prohibited from posting attachments, but the excel file and the dyn file are here:

They dyn is a work in progress (obviously). Applying the other parameters is still on the to do list. (one challenge at a time)

Continuing to play with this:
I can use a set.difference node to compare the Sheet.SheetNumber node from my list of existing sheets to the list of sheet numbers I need, which gives me a list of the sheet numbers that are different.


From that, I feel like I should be able to get a list of the indices of the sheet numbers on my list of desired sheets, and then filter my lists of sheet numbers, names and other parameters to include only those indices.
But, the IndexOf node is not doing it - I’m clearly missing something about how that node works.

1 Like

OK, I have found A solution to this - there’s probably a more elegant one, but this seems to work

From the SetDifference node, instead of “IndexOf” I used “ListAllIdicesOf” and then a flatten node, to generate a list of the index numbers for non duplicate sheet numbers. Then, for each of my lists, I used a List.GetItemAtIndex node to get a list of just the non duplicate sheets

1 Like

You could filter the list by testing if the strings are equal which will give you a true or false value in the same data structure, then use the Boolean filter node to pull out the ones you need, you can use the same bool list to filter all the other data too then do what you want with it. This could be create a new sheet with that data if it is false, or update an existing sheet if true.