How to extract only the last word of each row within a column

I would like to extract only the last word of each row in a column.

I have a lot of rows with product names (all different lengths and different amount of words) within one column.
Now I would like to extract always the last word of each row and write it into a new column.

For example. I have a column called “Products” and in the cells I have the following texts

One Two
One Two Three Four
One Two Three
One

Now I like to create a new column containing

Two
Four
Three
One

Does anybody have an idea?

One way you can do this is with the Cell Splitter and Column Aggregator nodes. Start with the Cell Splitter to deliminate on spaces, this will give you a column for each word. Then use the Column Aggregator to grab the final column in each row to keep, make sure to uncheck the missing box so you ignore those. That will just leave you with the final word.

Here’s a quick little sample workflow showing it.
Hope this helps!

Last%20Word%20Extraction

Last Word Extraction.knwf (8.1 KB)

8 Likes

That’s it! Thank you very much!

Very elegant solution. The only question - should be latest KNIME version used for example posting if it is not available yet?

Nice catch hah, a struggle of having multiple versions installed. These nodes aren’t new so all should be well but you’re absolutely right about that. :+1:

I’ve updated the workflow linked above to avoid any confusion.

2 Likes

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