Column Expressions Node - For Loop

I am really familiar and comfortable using Loop Nodes in KNIME. But I was wondering if it is possible to write a FOR Loop in the Column Expressions node.

I saw this: Column Expressions: Loop over all columns and create collection but I am interested in changing the value of specific rows in a For Loop like this:

change_row = [12, 13, 29, 74, 78, 173, 185, 198, 210, 238, 274, 278, 290];

for (let i = 0 ; i < rowCount(); i++)
      if (column("RowID") == change_row[i])

I feel like it in certain circumstances it could be more convenient to just have the loop run in the Column Expressions node than build it out in the workflow.

I appreciate any thoughts!

Hi @TardisPilot,

mmmh … why Column Expression Node, why Loop? You could use the Reference Row Splitter to split the dataset using a second table (change_row).

Best regards

1 Like

Hello @TardisPilot,

Column Expressions evaluates expression on each row so there is no need for loop in this case. Something like this should work:

arr = arrayCreate(1,3,5);


But agree with @Andrew_Steel that there is probably no need for loop and/or Column Expressions in this case.



Thank you @ipazin! The code you provided worked great. I made a couple of changes based on my need but otherwise it worked!

What I used:
arr = arrayCreate(12, 13, 29, 74, 78, 173, 185, 198, 210, 238, 274, 278, 290);


I thought for some reason I needed a loop, that’s the only reason why I had brought it up. Additionally, I like the idea of using the Column Expressions node here because it keeps things clean and simple and inside 1 node without the need to split and concat etc. (if I’m understanding correctly!).

Again, thank you for the assistance!

1 Like

Hi @TardisPilot,

glad to hear that. On the other hand you can also use Rule Engine as one node solution using ROWINDEX and IN operator. Like this:

$$ROWINDEX$$ IN (12, 13, 29, 74, 78, 173, 185, 198, 210, 238, 274, 278, 290) => “Negative”
TRUE => $Comp_Sentiment_Category$


1 Like

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