Number to String enforcing not working

Hello there!

I have a very annoying situation with the “enforce” option of the 2 blocks: “number to string” and “string to number”. I do not know if this is concerned only to loops, but every time the numbers/names of the column to include/exclude do change, the node sets itself on red light with an error triangle on it and stop working.

In short:

  • a “loop start” node load a file/table/csv/whatehever including column header
  • following there is one of the two infamous blocks (“number to string” or “string to number”) with the “exclusion” list empty and the “enforce exclusion” option enabled. This, if I get things correctly, serves to ensure any and whathever new column (of the right type) is automatically included.
  • the loop keep going, till a “loop end” initiate the next iteration

Guess what? on the second iteration these 2 blocks halt themselves and give errors. To solve the issue I open the configuration step, and just press “OK”, litterally doing nothing at all in the configuration. The lights switches to yellow and everyting’s fine ( I mean, 'till the next iteration…)

The most annoying thing is that if you check the console tab for error you always find something of the sort:
"WARN Number To String 0:1789 Column “Pippo” not found.
Which makes me thing the enforcing option is not working at all.

As a bonus challange: what I am tryng to do here is to convert an Int to a Double. I read a lot of threads but still cannot understand why there is not such node (before you ask, there are a lot of situations when an Int just won’t do…).
I have to convert int to string and string to double to do so. Since columns name/number changes everytime, math formulas is not an option, neither is to split the table and re-append after other types of conversion methods, since the “append column” node is by far the most time consuming node i ever used (sometimes it takes up to 70% of the total calculation time by just itself).

Thanks to everyone who can give me some insight!!

Antonio

Number to String enforcing not working.knwf (23.1 KB)

Hi @Suvrec

If you use the Math Formule (Multi Column) node you can enter as expression this (leave the rest as default)

afbeelding
This changes only numerical columns into doubles and it’s not complaining within a loop on changing names.

2 Likes

That’s a hell of solution! works like a charm!

Would you mind explain what exactly happening by that command?

Thanks so much!

A

The multi column node uses this $$CURRENT_COLUMN$$ to loop through each selected column and perform the formula on it. You can see it in the columnlist as CURRENT_COLUMN. Just double click on it, same as for a selected column, to include it in the expression.

Multiplying with 1 doesn’t change the value, but by specifying 1.0 instead of 1 you enforce the result to become a double. The other way around is possible too, but you would have to use the tickbox “Convert Selected Columns to Int” at the bottom of the configuration screen.

What I wasn’t sure of at first was whether it would would work in this loop with changing columns, but it does without complaints :slight_smile: .

2 Likes

That’s genius. Thanks so much, it helped a lot for my specific need right now and also provided a good insight on the way knime works.

Still, the problem on the 2 blocks remains. I do believe it’s a bug and I hope it will reach admins’ hears. I do not know if this is the best place to post for this purpose… ?

Thanks

A

Hi @Suvrec
Not sure which problem you still face. The Loop End node collects all results and moves columns with different names into new columns in the end-result.
If your input contains the same columnnames, it will put the results into the same columns. But if all the columnnames differ, like in your example, it will put the results into new columns.

You could change column names with Column Rename (Regex) node after the Table Reader, but if you have mixed types in your input (i.e. numerical, alphanumeric and dates) this would fail on those mixed types.
Besides that: even if it all numerical you would know anymore what is what if you have given them meaningless names like col1, col02 and so on.

Hi @JanDuo,

Thanks for your reply. I am actually not following you in this last reply… it is not a matter of the loop results. Infact, you can try the workflow I attached after exchanging the generic “loop end” node with a “variable loop end” node, and get the same result (see picture).

The bug I am referring is the one I tried to explain in the first part of my original thread: in the configuration windows (whichever of those 2 nodes) I move all the column to the “include” list, then check the “enforce exclusion” option; I put everything in a loop and start it.
Result: on the first iteration (iteration 0) everything goes fine, and all the column I originally included by myself are recognised and converted; during all the following interations (during which you are providing a different input table, with different columns) the converter nodes give off a red light and say “column “whatever” not found”. Obiously “whatever” was one of the column from the first iteration.

Now, shouldn’t the “enforce exclusion” prevent this error??
I am convinced it is a bug for the simple reason that at this point if I do the following: a) click on the configuration button, and then b) click on “OK”, and REALLY nothing else…then the red light become yellow and the node works again.

Hope I clarified it better, let me know, thanks

A

Ah, there was a misunderstanding on my side as well!. I’m on the same page now :slight_smile:

You want to see whether your initial finding is to be reported as a bug. Indeed that can better be answered by someone from the Knime Team.
I wouldn’t know whether this “enforce inclusion/exclusion”, which can be found in other nodes too, works for all those nodes in the same way or not.

Hello there!

first regarding the enforce exclusion. This is not working properly and there is already ticket to handle it (Internal reference: AP-13839). Will give it +1.

Hmmm. Did you see this topic? We have discussed it here in detail.

Multiplication is not necessary. Expression $$CURRENT_COLUMN$$ is just enough :wink:

Hope this helps!

Br,
Ivan

1 Like

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

Hello @Suvrec,

adding info that issue with enforce exclusion was addressed with KNIME version 4.2.2.

Br,
Ivan

2 Likes