Hi guys, I need to convert a string cell to number (is actually a double). However, the minus symbol is at the end of the string, and the node fails. I should first put the minus sign at the beginning and afterwards run the node, or use an alternative, maybe with the string manipulation node.
which is the fast way to do this operation? I have a huge data set, and performance is an issue. Thanks.
aworker
January 15, 2023, 10:31pm
2
Hi @Sgomezba
The -String Manipulator- node is quite fast. I would suggest the following instruction:
join( string( substr( "-", 1 - count( $ImpteNeto$, "-"), 1)), removeChars( $ImpteNeto$, "-"))
Just copy & paste the previous instruction into a -String Manipulation- node and replace the name of the column to correspond to your column name.
It moves the “minus” sign from the end of a string right to the beginning:
Hope it helps.
Best
Ael
6 Likes
thank you so much @aworker , it’s works perfect!!
2 Likes
My pleasure @Sgomezba . Glad it worked and thank you for validating the solution.
Best wishes,
Ael
1 Like
ipazin
January 16, 2023, 8:34am
5
Hello @Sgomezba ,
here you’ll find a regex solution (@aworker created workflow ) plus there’s a ticket to add this feature into String to Number node.
https://forum.knime.com/t/how-to-convert-string-column-into-number-with-negative-values/39655
Hi everybody,
I am running a txt file that has negative values with minus sign on the right such as:
717,31
717,31-
216,55
216,55-
244,19
244,19-
10,58
10,58-
The column is a string and it seems I can’t turn it into a number’s one. How can I move the sign on the left and turn into numbers?
Thanks a lot
Br,
Ivan
1 Like
system
Closed
January 23, 2023, 8:35am
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.