Please help me solve the problem below.
Sorry for the wording - English is not my native language. I have two problems. At the input I have a table with columns (data types are not important). I plan to select columns for processing. Columns are processed in turn. After the first column is processed, there should be a script that will check if there are any unprocessed columns yet, and if so, it will sequentially process these columns. That is, a loop is triggered, and inside the loop something like this happens:
We take the first column, save its old name in a variable, assign it a new unified name, after actions with this column, we take the original column name from the variable and assign it back.
We repeat with each column, and finish the loop.
I know how to do from in Java or Python, but is it possible to do this only through the nodes that Knime offers?
Thanks, I’ll see what’s in the threads. Perhaps this will solve my issue.
I managed to do my task, but there was a snag with one nuance. In the cycle, each pass is divided into iterations. At the output, I get a table where the iterations are placed under each other in the order of iterations, and the ID changes to ROW #0 (#1) and so on.
Is it possible to place the iterations next to each other, for example, based on the ID values, or is it easier to process the final table with iterations?
Your explanation is very clear, and yes — what you’re trying to do is possible in KNIME, though it takes a bit of node orchestration. You’ll want to look into using a Table Row to Variable Loop Start node to iterate over the list of selected columns, combined with Column Rename, Column Filter, and Loop End nodes. You can store the original column name in a flow variable, temporarily rename it for processing, then rename it back before the loop ends. It’s definitely doable — just a bit more visual than what you’d do in Python or Java. Let me know if you want a sample setup!
Hi @ElTsSikier
With the RowID node you can replace the RowID values with a new one. Place this node before the Loop End (Column Append) node. So every Loop you end with the same RowID values
gr. Hans
I actually managed to do what I had planned thanks to your advice.
If you are interested - I made a universal script that would put dates from excel in order (after all, there is a strange way of storing these dates. If the date is saved in the “general” format in the original file, then knime saw “455395” and could not convert it to a date). My script solves this. Moreover, the script had to work for any file, from the input data you only need to specify the columns for processing in the first node.
Part of the task was to make it so that with other original column names there was no conflict and the script was executed without errors. And this is necessary so that during any development I could copy the metanode and paste it into any project without wasting time on it. Now I will conduct tests on other files, and I can share if you are interested.
If only I knew how to do it.
I actually managed to do what I had planned thanks to your advice.
If you’re interested, I made a universal script that would sort dates from Excel (they have a strange way of storing these dates). Moreover, the script had to work for any file, from the input data you only need to specify the columns to be processed in the first node.
Part of the task was to make it so that with other initial column names there would be no conflict and the script would be executed without errors.
I actually didn’t get what I intended, thank you very much. If you’re interested, I made a universal script that allowed me to sort the dates from Excel (there’s a strange way to store these dates). When writing a script for any file, only the columns for processing in the first node should be indicated from the original data. Often the task should be done in such a way that with other original names of columns there would be no conflict and the script would be completed without errors. But this is necessary so that during any development I could copy the metadata and install it in any project without wasting time on it. Now I have tested other files, and I can share, if interested. I just know how to do this.
Excel data format.knwf (117.9 KB)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.