I am currently solving Advent of Code 2020 for learning KNIME.
On day 6, I want to split a string into rows of each character and have found a way to do this using Java Snippet. Is there any other way to do this?
Also, any other workflows for AoC 2020?
Hi,
I think you are looking for the “String Splitter (Regex)” node. Just activate the “option” set or row.
Unluckely I’m not an expert in regex so I cannot help regarding the needed expression
I went in search of the original Advent of Code question that was posed, and found it here. This will hopefully be useful to anybody wishing to understand what the challenge is.
It is an interesting question, and in the past I have used java snippet to break cells down into individual characters, which is one of the issues you face. I even wrote a component that did just that when I first started with KNIME
However, your question is how to achieve it without java snippet, so that rules out my component
Take a look at this… hopefully the annotations explain sufficiently…
I thought I’d add something about the use of regex here. I used regex, but not in String Splitter (Regex). Instead I used it in the String Replacer node, to prepare the data so that it could be split using Cell Splitter.
and what this does is “captures” every individual character
This is replaced by $1¬
which means take the captured character ($1 refers to “capture group number 1”) and writes it back followed by the ¬ character which I am using as a delimiter.
This delimiter is then used by the Cell Splitter to split out every character into a Set.
The String Manipulation was added in between the two because I discovered your data sometimes had spaces, which I wanted to filter out so they wouldn’t get counted. I could have alternatively filtered spaces near the very end of the flow (after the Ungroup) using Row Filter.