I’am dealing with an issue about the decimal seperator in Knime. I have a lot of data (550 colomns) with a wrong decimal seperator.
For example, I have average price and size, witch have a decimal point seperator. So I would like to convert this decimal point with a comma seperator.
But I have too much columns to do one after one. There must be a solution, but I don’t find.
Hi @Grayfox I assumed that you have your data already within KNIME and then you needed to replace your decimal separator. That is when my solution comes into play. If you have an example how your “wrong” columns look like and what your desired output is, I will try to make this solution work for your situation.
where would you want to see comma as the decimal separator? At this stage KNIME internally uses . as the decimal separator. So tables that you will look at inside of KNIME will show .. There is a related discussion here: Change standard decimal seperator. There is always a work-around of looping suggested by @HansS: loop over columns, convert numbers into strings and replace the dot with a comma in the string. But this will be slow for a large number of columns and you won’t be able to do math operations on the resulting strings.
I want to use comma seperator because I work with an excel output. and excel don’t like the dot when you do math operations, it’s return #value . So I need to replace this dot by a comma on Knime.
I’am sorry but I don’t understand how the solution of @HansS works.
Hi @Grayfox , like @lisovyi mentioned not the best solution, but see this workflow decimal.knwf (18.8 KB) how with String Manipulation node the “.” are replaced by a “,” for all columns.
As others have mentioned, there is no suitable way to do this - and there is an open issue in KNIME’s JIRA to implement this (where ‘this’ is the localization / customization of numeric formatting.)
You could do something like string manipulation, but then you no longer have a column that is a numeric data type, which seems like not what you want. Perhaps as a penultimate step to generating a report / readable text you could then do the string manipulation - depending on your use case.
Thank you for your workflow. It’s seems to work, but I have two difficulties.
As I said, I’am working with muliple columns and I have to select my columns in the Column Splitter Node.
So I tried to use Regex selection, but I don’t know how to reverse my selection with the Regex. Instead to having my selection in the Top, it goes on the bottom.
The regular expression used is : (.*)(Price $.*|Size.*|Target.*) and I tried to reverse this selection by using the ^ caracter. But I don’t know how to use correctly with multiple excluded parts.
Finally the very important thing is that I need to have in the output the columns in the same position since the begining. And when I use a Columns Splitters, all columns are only selected if they have a point (price, size …). So these columns should go back to the original files at the same position.
If it’s not clear, do not hesitate to ask me for clarification.
Again, thank you very much for your help.
I’m not so good in RegEx, but @armingrudd is. Is it an solution to switch your upper output port downstream and your lower output port upstream…? And maybe this site regex101 is helpfull for you.
The selected columns in the Column Splitter node go to the bottom port. There is no difference between the output ports.
However, If you insist to send the columns which their name begin with “price”, “size” or “target” to the top port of the Column Splitter node, use this regex: ((?!(price)|(size)|(target)).)*
This will select all the columns that do not begin with these names. So the columns which their name begin with price, size or target, go the top port.