Splitting cell to columns

Hi,

I have to split a cell into multiple columns, the split needs to be done based on position. All values in the cell need to be split into columns. I have tried the cell splitter node by position but you need to specify all col names and splits for it to work and the number of splits here will be more than 30. Is there a quicker way to do this?

Example :

0102134 → 0,1,0,2,1,3,4

Comma here denotes different columns

image

Hi @Pranjal_m, So just to check understanding… Every single character in the cell becomes a new column, including each of the “?”… ?

Assuming this is what you want to do, it can be done with a java snippet. I’ve added a workflow here using different (but similar) options. The first is a java snippet that converts the column into a string of pipe-delimited characters, and then uses Cell Splitter on that.

The second is based on an even better (and less code) idea from:

which is to still use a java snippet but this returns the cell as a String Array column that can then be split using a Split Collection Column.

KNIME_split_cell_to_columns.knwf (27.3 KB)

You will see that to make it portable, without editing code, I’ve packaged up the second snippet as a component which you can also find here:

6 Likes

Thanks !! this is exactly what i was looking for

2 Likes

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