Maximum Length of String Values in Each Column

Hi,
I’m pretty new to Knime, and just trying to learn as I go. I’m trying to do something which I feel should be easy, but can’t seem to find the right node.

I’d like to report the maximum length of string values in each column of a table.

Any suggestions?
Thanks!

Hi @davidbaker Welcome to KNIME Forum

I don’t what you mean by “maximum” length.
With the String Manipulation (Multi Column) node, and the length function, you get the length of every string. See if this help you out.


gr. Hans

3 Likes

Thank you Hans! This (using Replace selected input columns), combined with a groupby(maximum) did the trick.

I had gone down a rabbit hole looping through columns one at a time, but this is way better.

1 Like

Hi @davidbaker , and welcome to the KNIME community.

All I’d add to @HansS 's post is that If you are wanting to get max lengths for just the string columns, with a single max value for each column (i.e. the value representing length of longest string in each column) , I’d probably add a Column filter first, ahead of String Manipulation (Multi Column)

Reason for the filter: Firstly I assume you only want lengths from String columns, and (oddly) the String Manipulation (Multi Column) has no ability to filter by data type. This becomes problematic if you have other data types because String Manipulation (Multi Column) will break if presented with Long or Binary datatypes, and you have to ensure they are in the Exclude list or else it comes up with horrible (meaningless to people) error messages during configuration.

3 Likes

Thank you @takbb, what you suggested is exactly what I found I needed to do. Just to give the end to end process, I also unpivoted the table, filtered out the extra RowID column it created and renamed the ColumnValues column to MaxStringLength. Now it does exactly what I need. Thanks again to both of you.

1 Like

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