Convert String to Real/Number

Hi,

I am trying to convert a string column (0.0012; 0.00000418; 0.0005…) into a number. When I use the conversion node “String to Number” I get a column with (0.001; 0; 0.001…).
How can I convert to (0.0012; 0.00000418; 0.0005…) that are considered as Real?

Thank you
Delphine

Welcome to the KNIME forum.
It seems you have more then 1 value in the column. So you need to split it in number of columns using


using ; as delimeter. Then unpivot result table, then using String Manipulation node function ToDouble() convert strings to numbers and finally pivot it back in line, if you need.

2 Likes

sorry, I may not have been clear, the column has only 1 value per row
0.0012
0.00000418
0.0005

Then you need just String Manipulation node as above.

that is what I used and the return values are:
0.001
0
0.001

where they should be:
0.0012
0.00000418
0.0005
but as number

This seems like a rendering problem in KNIME - what version are you using? I see the same behavior as you describe in 4.0.1, but it’s a red herring - the double values are actually there as can be seen in the output of the Java Snippet node in the attached workflow - it is just that the output table renderer is rounding / truncating the display of double values.
delphine’s numbers.knwf (7.5 KB)

2 Likes

When use Column Expression node with the same function.

I use version 4.0.0 and it seems it is not compatible with the workflow you sent. Do you recommend to upgrade?

you are right, when i read in excel the numbers are correct
thanks!

Yes - i would always recommend upgrading from a x.y.0 release when it comes out.

Glad you see it ‘working’ correctly - i’ll bring up the rendering issue internally - sorry about the confusion.

1 Like

No Problem, Thank you for your help!

1 Like

@dcollin1 i had no idea this was there, but if in the output data table view, you right click on the column header for the Double value column, there will be a context menu with an item titled “Available Renderers”. Under this you can choose Full Precision which will show you non-truncated values.

It is the rendering. If you right click in the column heading and choose the Full Precision option you should then see what you want:

image --> image

If you want to always see the Full Precision option, then you can change the default in the preferences:

Steve

4 Likes

perfect! thanks to both of you

2 Likes

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