Column value abbreviation

Dear Knimer,

Please need help to get the node details in below format

Column Expected result in Knime
swizterland-april-monday-america Sw-Ap-Mo-Am


Hi @Prag_Mor

There are a number of ways this could be achieved. Attached is a method that springs to mind.

image KNIME_abbreviate.knwf (10.4 KB)

1 Like

Thanks for the solution. @takbb
But the below problem arises:

swizterland-april-monday-america Sw-Ap-Mo-Am
swizterland-april Sw-Ap-- (Expected value is Sw-Ap)

In column Combiner how to prevent hyphens to be added if there is no value.

Column Expected result in Knime
swizterland-april-monday-america Sw-Ap-Mo-Am
swizterland-april Sw-Ap Sw-Ap–

Hi @Prag_Mor

I think maybe you are going to need to state all of your requirements :wink:… how many different variations of terms does this need to allow for?

Maybe one of these solutions. It really depends on what other examples you have.KNIME_abbreviate 2.knwf (21.4 KB)

image image


Thank you @takbb
It worked


For regex you could also try ^\w{2}|(?<=-)\w{2} and then a groupby because the extractor splits to multiple rows. The result is not capitalized however. Still fun challenge.


Hi @Daniel_Weikert , is that using the Palladian Regex Extractor?

OK, yes. Nice regex and great idea. Building on that… what if we find a way to capitalize the “words” prior to the regex? I just discovered that String Manipulation’s capitalize function allows specification of a delimiter:


Then we apply your Regex, but modified slightly so we also take the leading hyphen along for the ride too.

(I got a bit lost using the extractor to split to rows, when I had more than one row as input data, as I then had a group of rows with no obvious (to me) way of assembling them back into their original row-groups. So I tried splitting to columns instead.

If we tell it to split to columns we get this:

Replacing missing values with zero-length (empty) strings, we can then combine them back with the Column Combiner. So that gets it down to 4 nodes from 5, without writing the logic “in code” (as I did in the three-node option2)

Thought it would be nice though to find away of avoiding having to deal with those annoying “missing values”. Doing the Regex extraction to a list (instead of to columns) looked promising because it automatically skipped missing values from the lists it generated


Only trouble was… finding a way to convert the collection back into a string! I thought that ought to be straightforward. Then I discovered what others had discovered before me… and it seemed to cause more trouble than I was trying to avoid!

My search led me here:

Which then led me here, with a node by Vernalis:

and that got it down to three nodes with no coded logic (albeit needing to use what appears to be a useful community node). Any other takers?

Yes I agree, a fun challenge! :slight_smile:

KNIME_abbreviate 3.knwf (35.3 KB)


yes I used the palladian regex extractor.

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