Hello,
I am trying to filter out (remove, purge from original list) items of sublists which are not the items that are contained in a list of strings as input, so if any sublist contains those input strings, remove only the items of that sublist that do not contain the string list, and leave at it is the rest of sublist that do not have ALL the string list items requested.
I am trying this in python:
-
find if a list of sublists contain a list of strings within each sublist, so get true or false for each item.
-
if it is contained give me true for the entire sublist that contains the strings, if not, give me false.
-
if the sublist did not contain the list of strings, make the boolean result of step 1 as True for those items of the sublists that did not contain the strings. In Dynamo core nodes what I would do is to ask if All items of sublist are False, so if it is true all are false, make all items of those sublists as True and leave the other sublists as they are. NEED HELP
-
Filter the true values, get rid of the False values.
For example:
OriginalList=[1,2,3,4,5],[0,1,1,3,6],[0,2,3],[2,4,5],[Empty List]
SearchListStrings=[1,3]
Result wanted step 1=[true,false,true,false,false],[false,true,true,true,false],[false,false,true],[false,false,false],[false]
Result wanted step 2=[true],[true],[false],[false],[false]
Result wanted step 3=[true,false,true,false,false],[false,true,true,true,false],[true,true,true],[true,true,true],[true]
Result wanted step 4= [1,3],[1,1,3],[3],[2,4,5],[Empty List]
With Dynamo OOTB nodes it is resolved like this:
FILTEROUT.dyn (23.2 KB)