Search unknown word in different columns

Hello,

I’m struggling with my data. Here’s an example of what I am trying to do:

col1 | col2 | col3
red | yellow | blue
red | blue |
blue | blue | yellow

I’d like to have word counted:

col1 | col2 | col3 | red | yellow | blue
red | yellow | blue | 1 | 1 | 1
red | blue | | 1 | 0 | 1
blue | blue | yellow | 0 | 1 | 2

I don’t know a priori the colours in the original table. So I need to search for the word, put it in a column, ccheck if it is in the row and once all rows are checked, I need to find the next word and so on…

Any suggestion?

Thank you

Hi @jquadrada

Interesting question. Below you will find a possible solution. The first branch provides a simpler solution but without counting the occurrences of colors per row:

The second branch provides a more involved solution which should be generic and fully answer your question:

20210927 Pikairos Search unknown word in different columns.knwf (124.1 KB)

The solution I have uploaded is generic and it does not care of the different number of colors or the number of columns to take into account. It should hence be generic.

The solution is involved although it does the job. I would be curious about a simpler solution for this interesting problem.

Hope this helps.

Best,

Ael

4 Likes

Hi @jquadrada

See this wf search_unknown_word.knwf (14.9 KB). I think it does the job also, but you need less nodes.


gr. Hans

7 Likes

Hi, thank you. I’ll check it and let you now!

1 Like

Hi, thank you. Looks great. I’ll check and let you know!

1 Like

Hi @jquadrada

@HansS is shorter and simpler so the best solution. I should have thought of it :wink: !

Just a possible improvement to @HansS’s solution. If you want to make it generic, you will need to add to it the regular expressions I’m using in my workflow for column selection in the node configurations. Otherwise, it will only work for the given number of columns.

Hope this helps too.

Best,

Ael

4 Likes

Hi @aworker !

Yes! @HansS solution fits perfectly! Thanks both for your time!!!

4 Likes

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