convert exp. number

Hello,

the data which i loaded in knime has the following format:

1.0E-5 Datatype is a String.
is there an easy way to convert it a format like this 0.01?
0.01 is correct in my case.

I already tried it with string to number node, but this did not work…

Thanks a lot for your help.
Kind regards

Josef

Hi @jhoc, the String to Number node will actually convert 1.0E-5 to a Double, but the problem you are probably experiencing is that when you view it in a KNIME table, the standard renderer shows it as 0 so it looks like it hasn’t done it properly.

(Of course 1.0E-5 is actually 0.00001 rather than 0.01 )

Example:

Changing the renderer by right-clicking on the column title, we can see that the Row1 value isn’t actually 0, but has been translated to the correct Double value:

It shows 0.01 format for 1.0E-2, but it still doesn’t show it in 0.00001 format for 1.0E-5

I don’t think there is a renderer that will show Doubles to several decimal places. If you need the number formatted in another way for output somewhere, I think you would have to convert it back to a String.

To do this you can use the (strange sounding) Round Double node and adjust the formatting there as it returns to a string, so that it shows as a numeric value with multiple decimal places. Specify the number of decimal places that will cover your data requirements.

This gets closer but has the (probably) undesirable effect of returning multiple trailing zeroes.

Removing these can be performed by regex, using String Replacer using regex.

This regex pattern should (I hope :wink: ) return both positive and negative numbers with all trailing zeroes removed after the first 2 decimal places:

Pattern : ([\-]{0,1}[0-9]+\.[0-9]{2,}?)[0]*$
Replacement: $1

Scientific notation converted to non-scientific notation with decimal places.knwf (11.7 KB)

2 Likes

Hello takbb,

thanks a lot for your great help and this big effort.
This solution worked for me.

Have a nice day

Josef

1 Like

Glad it worked for you @JHoc , and thank you for marking my answer as the solution.

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