Double to string

Good evening guys, how are you?

I would like to remove the “.” of this double string, but I cannot use string manipulation.

Can you tell me how I can do it? I need to transform it into a whole number, but it needs to be example 29471

KNIME_project.knwf (5.1 KB)

@Gabriel2020,

You can use the Math Formula node and write an expression like “floor($column1$ * 1000)”.

Also, ensure to check the box labeled ‘Convert to int’

for your reference, I have attached the workflow and images.

KNIME_project.knwf (5.0 KB)

Output:

2 Likes

Hi @Gabriel2020,

remember: you can’t handle numeric formats in String Manipulation as you can’t handle strings in Math Formula.
Use the Column Expression node if you want to avoid this kind of issues!

If you want to remove the “.”, if depends on how you want to remove it: do you need a conversion assuggested by @tqAkshay95 or just a plain removal?
In case of the second option, use column expression with this formula:

replace(column("column1"), ".", "")

Have a nice day,
Raffaello Barri

2 Likes

Although Math Formula cannot interact with strings, it’s not totally the case that String Manipulation cannot handle numeric formats, in spite of its name. :wink:

It’s often underutilised as a node because it isn’t always obvious what it can achieve.

It is correct to say that it cannot perform string replacement directly on a Double, but it can use it in string transformations, if it first converts the Double to a string.

So the following would return the Double converted to an Integer using string replacement, as an equivalent of @lelloba’s Column Expression:

toInt(replace(string($column1$),".",""))

and it can also do the equivalent of @tqAkshay95 's Math Formula approach:

toInt($column1$ * 1000)

see here for more discussion on String Manipulation “hidden features”

4 Likes

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