Count of consecutive "1" from top of column and "0" from bottom of column

Target.csv (273 Bytes)

Hello, this seems slightly different from similar posts regarding counting. I’m looking to count the number of consecutive "1"s from the top of column A but also count the number of consecutive "0"s from the bottom of column A. So the output I’m looking for this dataset would be “1” = 1 and “0” = 12. I’ll probably sum this up later but I can figure that out. It’s this step of my workflow that has me stuck. Thank you for any help!
m

What you’re trying to do isn’t very clear. Also what’s the second column do? Could you provide a manually created output that shows what you want?

Sure thing and thank you for your time. I’ve recreated the file with three different cases. Consider column A the actual data. Consider column D the logic that needs to happen. Column F and Column G are the outputs I’m seeking, not necessarily on the same file but written out somewhere. Whatever you think is easiest I’m sure is fine.

Just in case this is unclear I’m only trying to count the first instance of "1"s from the top of the list and the first instance of "0"s from the bottom of the list. I’m not worried about what happens in between.

Thanks again and please let me know if there is anything I can explain.

Target.xlsx (12.0 KB)

I’m not ignoring you. I’m struggling with a solution. Not as easy as I thought. I may have brain freeze. Maybe someone else can weigh in.

1 Like

Hello, I offer a reference method: Transform the specific sequence into a string, and then the regular expression can be applied.

PS:This workflow was created using the KNIME 5.3 version. There might be issues when opening it with lower versions. Among them, the node “String Spliter(regex)” was called “Cell Spliter(regex)” in older versions.

count.knwf (16.2 KB)

8 Likes

Nicely done. Very good solution.

2 Likes

Thank you so much @tolmljh. Very simple yet highly effective. Great stuff and thanks again. I hope I will be able to use this logic in the future. Thanks again.

1 Like

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