Inserting new rows into existing table

Hi there, I have a table that currently looks like this:

image

But I want to insert some rows so the output looks like this:
image

The new rows are values can be hard coded.

I’ve read many posts about inserting new rows but none of them fit the purpose of what I am doing here which seems very simple. I’m quite new to knime, this is only my second post.

If someone can help, that would be great. Thank you.

Hi @ViTLe

Let’s say that the rows you want to insert are all in a table that I will call Table 1 with respect to your initial table that I will call here Table 2. The operation one needs to do to “insert” Table 1 rows in Table 2 is a “concatenation” of tables. Hence the -Concatenate- node should do the job :wink:

If you need to add single rows every time before or after those already existing in your final table (here Table 2), then you would need to use several concatenate nodes or alternatively use just one within a loop if needed. Please be aware too that the last version of this node allows to increase the number of input ports (the 3 points “…” on the node), so if you have more than 2 tables to concatenate at the same time, then just one -Concatenate- node should do the job.

Hope this helps :blush:

Best regards,

Ael

2 Likes

Hi Ael,

Thanks for replying so quick. So it looks like the easiest way for me to do this is to create another table with the grey rows and then simply concatenate.

The first image above is an output which resulted from pulling data from a live database so the data in the first table will always change every time I refresh the workflow. The screenshots were just dummy data I quickly popped into Excel because I didn’t want to share confidential data in my Knime output.

I will create a static table in knime with the grey rows to add to the table at the very end then :slight_smile:

Thanks again! I thought it was some complex fancy way of doing this but it was quite straight forward.

Hi @ViTLe

My pleasure. Yes exactly the way you are explaining how to solve it :wink:

Best wishes,

Ael

Hi Ael again :slight_smile:

I just tried this solution and instead of adding the new rows directly under the existing columns, it has created new columns like this:

Do you know how to change this? is it possible with the concatenation node?

Thanks again.

Hi @ViTLe

Several hints :wink::

  1. Use Table creator to “hard code” your Table 1 (the one with the 3 first text rows)
  2. Make sure that when integrating the data in the configuration dialog of the -Table Creator- node, you set too at that time the name of the columns, as follows:

This makes sure that the concatenation is done based on column names, the first Table 1 (hard coded) being the reference table.

  1. Inverse the order on the input port connections: Hard code table (Table 1) should be connected to 1st input port and then Table 2 (your numerical data) to the 2nd input port.

Hope this helps.

Best

Ael

6 Likes

This worked like a charm!! Thank you!! Sorry it took me so long to reply. I had to work on that project and only got a chance now (being in Australia and all)

2 Likes

Lovely, I’m happy it worked :grinning: :+1:!

Thanks for validating the answer and best wishes for your KNIME project :blush: !

Ael

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