Replace values

Hi all,

Can you help me with the following:

I’m uploading data and I get some “?” where the cell should be empty actually: So I guess missing values are shown as “?”. How can I avoid that, instead of “?” I just need an empty cell.

image

Thank you a lot

Best
Markus

Hi Markus,

you can use the Missing Values node for that:

It allows you to specify a replacement, e.g. just an empty string for string cells with missing values.

Does this help?

–Philipp

6 Likes

Hi @Markus3003 , that is correct, Knime shows a cell with missing values (such as NULL) with a red “?”. I put the emphasis on red, because you could also have “?” as data, in which case, it will be a black “?”, like any other data.

Regarding your question, may I ask what you want to remove the red “?”? It’s just a display thing in Knime. Knime is not actually adding anything there, it’s just how it displays empty/uninitialized cells.

To not see the red “?”, you can replace the empty/uninitialized cells with an empty string. But that would change the data. These cells would no longer be NULL/empty/uninitialized. They would be converted to an empty string of “”, and there are a few ways to do this. You can do this via the Missing Value that @qqilihq suggested, or via String Manipulation or via Column Expressions, and via some of the available programming languages that Knime support.

Do you really want to change the data? Will there be any conflict with existing data? Will you want to distinguish between a NULL record vs record with an empty string? Would you want to count how many missing records do you have for example? This is straight forward to do if the missing cells stay as missing values.

Perhaps if you explain the reason behind wanting to remove the red “?”, then we may propose the proper solution.

6 Likes

Thank you @bruno29a !

What I actually want to do is:

But it is not working for the fields with “empty values”

If I click “insert missing values as null” I have “null” there, but I need it just empty.

Thank you and Best,
Markus

Hi @Markus3003 , yes indeed, join() will not join with empty cells. It will return empty.

There are a few ways to do this. It looks like you are using String Manipulation, which is very limited. It’s better to use Column Expressions in these cases where you can check for empty cells and apply if statements (if empty, replace with “”). You would probably need to do this for each of the cells you are concatenating though, in case any of them is empty in the dataset.

The simplest ways to do what you want to do is to use Column Combiner or Column Aggregator, which both can concatenate empty cells. It’s just that both concatenate empty cells as a string “?”, which you can then remove via String Manipulation.

I put something together quickly using either node, and it looks like this:
image

Input data:
image

Result via Column Combiner:
image

Result via Column Aggregator:
image

Here’s the workflow: Concatenate columns with empty cells.knwf (13.3 KB)

3 Likes

Thank you a lot @bruno29a

No problem @Markus3003 , happy to help :smiley:

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