How to import knime class?



I am new to Knime and Java so excuse my ignorance. I'd like to import the "rowIterator" class into a java snippet so that I can parse through my table. How would I go about importing/implementing it?


Thanks so much,



You can simply parse through the table by using any column from the Column List and call $my_column$ which is type-casted to the actual Java value, for example if you have a string column, you can assign the value as: String str = $my_column$. In each call of the script you get one row and one value for each column. If you need access to a previous row or need to store accumulated values, use the Global Declaration block.

I've used the Global Declaration block previously to build up accumulative data running down a table - but you mention accessing a previous row this way - could you give an example?



Sorry for being imprecise. In the Java Snippet dialog you have two blocks, one is executed for each row, the other one holds member that are available from the previous runs. If you need to have access to an entire row, you need to extract all values by accessing the actual column and store it inside a variable. Let's assume you want to compute are running sum, the Global Variable Declaration would read as:

Double sum = null;

And the Method Body:

if (sum == null) {
  sum = $column$;
} else {
  sum += $column$;
return sum;