removing string from List

Hi I have the following data structure:

Name | List_of_criteria | Criteria1 | Criteria2
test1 | X, Y, Z, A, B, C, D | X | Y
test1 | X, Y, Z, A, B, C, D | A | C
test2 | G, H, I, J | G | I

I know that Criteria1 and Criteria2 are elements of List_of_criteria.
Now I want to remove either Criteria1 or Criteria2 from my list and give them a new name.

For starters I would be happy to just make a new groups:
Name | List_of_criteria
test3 | X / Y (doesn’t matter which one)
test4 | A / C
test5 | G / I

Ideally I even realise that test3 and test4 can be combined, but that is not important at the moment.

Thanks for your help.

Hi,
I don’t really understand. What happens if the criteria is not in the list at all? And what do you mean by “remove either Criteria1 or Criteria2 from my list” if in your result table the list does not appear at all.
I think what you are looking for is the String Manipulation node. This provides for example the indexOf() function, which you can use to check if a criteria is present in your list.
Kind regards,
Alexander

Hi there @Shaller,

if as you written you know that Criteria1 and Criteria2 are elements of List_of_criteria then Column Splitter should do the trick to remove Criteria 1/2 from your data set and have it in new one. From there you should add Name column with new names. Do you want to add names automatically or manually?

Regarding combining GroupBy should help there. Define columns that are criteria for combining and select appropriate aggregation method.

Br,
Ivan

Hi,
In pseudocode it would be something like this

for element in list_of_criteria {
for elem in list_2 (contains criteria1 and criteria) {
if elem == element {
remove elem from list_of_criteria and make a new list
}else
continue
}
}

I hope that clarifies my question

Hi,
Please have a look at attached workflow. Is this what you would like to have? You could also do everything in the Column Expression, so you just need two nodes, but I think the String Manipulation is more elegant :wink:
Kind regards,
Alexander

ListOfCriteria.knwf (8.6 KB)

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.