Convert String to Number

Hello,

I am a beginner in Kmine and I would like to know how I can convert string cells into numerical cells. I used the String to number node but it said that it could not parse the values in my column. In the node CSV reader, I took a closer look to the data and saw that the column that I wanted to convert contains string values with numbers like for example -189,857365 or 793,4422258. I selected the comma as decimal separator but it didn't work.

What can i solve this problem ?

 

Since those numbers aren't regularly formatted, I guess you will need to use a string replacer to cut out the commas, then the string to number node to convert it.

 

thank you for your answer

What do I have to select when I have to configure in the String Replacer node ?

Personally I would use the String Manipulation node as you want to replace the comma with nothing, which I don't believe the replacer can do?

 

This is what you want for the String manipulation:

 

replace($YourColumnName$, ",","") 

 

I had to parse the converted value as a double as int didn't work. 

 

However you could do this all in one String manipulation node with either of the following:

  • toLong(replace($Number$,",",""))
  • toDouble(replace($Number$,",",""))

Cheers

 

Sam

 

1 Like

You can use regex mode to replace the character with nothing, just be sure to check the replace all occurences option.  Both approaches should work fine.