I tried to convert 11,312,918.2 into a string but I get this 1.13129182E7 as the output which is incorrect. My requirement is add 2 decimal places in to this number 11,312,918.2 where answer should be 11,312,918.20.
I went through other similar topics but no one contained the answer I am looking for. Could somebody help me please?
I do not know whether there exists a node in KNIME that converts doubles to integers or longs whilst preserving the format you want. For me, “11,312,918.20” is just a possible (more human) string representation of “1.13129182E7” among many possible different ones and eventually, if no node deals with this, the following workflow may be a solution:
I just created a new KNIME node which uses Python to format numbers to strings. It uses the core Python functionality, so there is no need to install any additional Python dependencies.
The -Round Double- node rounds at the right number of decimals and allows the direct conversion of the rounded double to a string in different formats as shown here below, but non of them add comma separators to the string.
Am I missing anything at the node configuration ? Thanks in advance for your feedback.
you are not missing anything. There’s no comma as separator configuration option in this node. I just presented option to get string without exponent easily. Regarding number formatting there have been a lot of topics regarding it and believe there are one node solutions using regex (and probably couple of components) to deal with it. Here I share one:
Thanks for the feedback. I like your solution based on Java as suggested in your post. It is equivalent to the one by @DiaAzul but instead of being based on Python, yours is based on Java.
It would be nice to have a dedicated KNIME node to format numerical data once it is converted into strings in the way the .format() method does in Java and Python
Thank you for this solution it worked. The data set that I had to work was small data set hence I tried your solution first and it worked. I will try the same solution with a large data set and will let you know the outcome. thanks again.
Thanks for the feedback and for validating the solution. Please let us know eventually if the solution is fast enough. Based on your feedback, an improved solution might be brought forward.