Please does anyone have a solution to convert columns which have been detected as Boolean into the string data type?
I have multiple columns from multiple tables, so I need a solution that does not require the specification of a column name or the provisioning of dummy column headers. I have already been able to isolate the Boolean columns using the column splitter node, now I just need something to make the data type conversion.
Looks like I have found a cheat by coincidence, or shall we say a serendipitous blessing from the universe.
Step 1: Isolate the Boolean columns by setting the Boolean data type filter in the column splitter node.
Step 2: Run the columns through the number to string node
Step 3: Use the multi column string manipulation node to replace ‘0’ with ‘false’ and ‘1’ with true.
Step 4: Use the column appender node to join these processed columns to the rest of your data.
This solution should work with varying tables and column names since I am using data type filters and multi column nodes.
For the number to string node, ensure you include unknown column names, and enforce exclusion with an empty list for the multi string manipulation nodes.
This works only if the setting for any unknown new column is set to string. If it is set to default, once I change the source table, the new Boolean columns still come through as Boolean.
Hi @TosinLitics , this is not a “core” solution to your question, which I feel you already have a solution for, but is instead a shameless plug for my Rule Engine (Multi Column) component
It has a slightly extended syntax over the standard Rule Engine, but works more or less the same way. As you can see below, it works across multiple columns using a $CURRENTCOLUMN$ similar to the way String Manipulation (Multi-Column) works, but also allows you to specify column type within the rule, by using "<CURRENTCOLUMNTYPE>" (rule needs to include the double-quotes as shown below)
The following rule would convert your booleans:
"<CURRENTCOLUMNTYPE>"="Boolean value" AND $CURRENTCOLUMN$ = "true" => "true"
"<CURRENTCOLUMNTYPE>"="Boolean value" AND $CURRENTCOLUMN$ = "false" => "false"
TRUE => $CURRENTCOLUMN$
I’d like to think that one day, KNIME may have a similar extended multi-column rule engine built in (it really should have one), and this gives idea on how it might work.