Looping through column

Hey Everybody,
I'm quite new to KNIME and have a question about how to loop through a column. Well I have data which I read from a csv-file. Each of my rows represents one second. In column 8 I have values which are either 1 or 0.   Now i want to loop through this column and want to count the number of 1s until a 0 apperars. Then I want to start counting at 0 again. The result for each row should be added as a new column.
I'm used to work with Matlab,so my Matlabscribt would look somehow like this:

for m=1:table.length

if table(m,8)= 1


elseif table(m,8)=0




table represents my data table and count is the vector I  add as new column.

My ideas to implement this with KNIME would be to use a Java Snippet or maybe some loop, but I don't really know how to do it. So I appreciate any help!

Regards, Daja



Hi Daja, 

It's quite similar, see the attached workflow and snippet configuration screenshot. The trick si to declare a system variable, and then your condition.

int time = 0;

// your code

if (c_events==1){
  out_timesi = time;
  time = 0;
} else {



Thanks a lot Aaron! This worked very well and I understand the Java Snippet much better now!