Filling empty strings with previous row's value

Hello there, 

So if I have a string column with some empty rows, how I can fill the empty row with the previous row values

Hi, you can use the "Missing Value" node exactly for this purpose.

3 Likes

it seems missing value node is just for none-string fields and does not work with string columns. 

Hi, I am also interest in this topic. I’ve used “Missing Value” in certain circustances with an good result. But right now I am trying to clean a file where empty cells are fill with character “-”. I’ve tried to replace “-” for nothing and then, use “Missing Values” but it isn’t working. After the replacement don’t detect cells as a missing value so the step doesn’t work.

Has someone other function to fill down empty cells or cells with a special character?

Hi there @jorlaru,

welcome to KNIME Community!

Missing Values node detect only missing values which are denoted in KNIME with red question mark. You replaced “-” with nothing and actually you got empty cell which is not interpreted by KNIME as missing value. How did you replace “-” for nothing? Some kind of loop? Probably the easiest way is to build your logic in a way if there is no “-” use value from column otherwise don’t do anything which will replace it with missing value. Rule Engine and Column Expressions nodes both work this way :wink:

Br,
Ivan

3 Likes

Hi, first of all thanks for your help.

I have 2 ways to replace “-”. One is using STRING MANIPULATION and in the expresion replace($Column$,"-",""), the other one is using STRING REPLACER (Pattern = - and Replacement text “”). At the end is the same. At this point I have two questions, once, I have to create a node for each column, which is not very productive when you have 10 columns to change therefore are there any way to change different columns in only one node?.
Second, after that work I am in the same situation, I am trying to do what you are saying but how can I write the formula to do that loop? $Column$ = “-” => ¿$$ROWID$$-1?

Hi there @jorlaru,

you can do a loop and in each iteration perform replacement in one column. Something like this:

Looping

Column List Loop Start node takes one column in each iteration. Column Expressions node performs replacement using If/Else clause together with MissingValue() function. At the loop end columns are appended.

Here is example on KNIME Hub. Take a look and if any questions feel free to ask.

Br,
Ivan

2 Likes

It works, Thank you very much. Great help.
It’s my first experience in this community and I have to say It is a great experience. Again, Thanks for the help.

2 Likes

Hello there!

With new, 4.2.0., KNIME version now there is String Manipulation (Multi Column) node. Loop is no more needed in case like this!
https://www.knime.com/whats-new-in-knime-42#ux-improvements

Br,
Ivan