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??
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?
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.
ok, let me know if you have trouble with the loop. The KNIME equivalent of the VLOOKUP function is the Cell Replacer node.
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?
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?
Unfortunately I can’t share the workflow. What I have done is the following:
- Using “Table Creator”, I have added all the columns which are needed to be added
- 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.
- 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.
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.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.