Adding New multiple Columns

Hi All,

I am new to Knime… I have a requirement where I want to add 10 new columns to an existing excel and perform some actions to fill the column. My query is, is there an efficient looping method where all the columns can be added simultaneously or one after the other?
Can I maintain a collection like Array and loop and add the columns??

1 Like

Hi Pearlb,
welcome to the KNIME Forum. How do you want to create the columns? Do they only contain constant values. For adding 10 columns in a loop, you can use the Counting Loop Start, then your logic to create the column, followed by a Loop End Column Append. Does that help you?
Kind regards
Alexander

2 Likes

Hi Alexander,

Nope, the columns that are to be added will get their values based on a VLOOKUP function which is to be performed on them.
In the mean while I will try to work on the loops based on the suggestion given by you.

Hi @Pearlb,
ok, let me know if you have trouble with the loop. The KNIME equivalent of the VLOOKUP function is the Cell Replacer node.
Kind regards
Alexander

Hi Alexander,

So my issue is that I have an excel file where I have to add the 10 new columns. Once these columns are added, I have to perform VLOOKUP or lookup these values from another excel file based on the “ID” column in both the files. I was able to work with loops, although what i was looking for is how to run a loop where for each iteration the column name is passed?

Hi @Pearlb,
can you share the workflow you have right now, maybe with some annotations? Generally, you can loop through columns using the Column List Loop Start, but in your case the columns do not exist yet. So maybe you can use a Table Creator to create a list of column names, then loop through that using a Table Row to Variable Loop Start?
Kind regards
Alexander

Hi Alexander,

Unfortunately I can’t share the workflow. What I have done is the following:

  1. Using “Table Creator”, I have added all the columns which are needed to be added
  2. With “Excel Reader”, I have read the file (File1.xlsx) and using “Column Appender” my file now is updated with all the 10 new columns.

Now the action that I need to perform is that reading another file (File2.xlsx), I have to lookup the “ID” column from File2.xlsx in File1.xlsx and update the new columns accordingly in a loop.

  1. I have started the loop using the “Column List Loop Start” node. Within it, I want to start the vlookup process. I tried using “Cell Replacer” but am stuck.

Hi,
if everything is done by ID, you don’t even need a loop. You can simply use the Joiner node to join the two tables by ID. The result is one table with the columns of both tables.
Kind regards
Alexander

1 Like

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