Function to sort a column by intervals when 0 changes to 1

Hey there!

I was just wondering if you could help me with this. I have some data I want to divide into different files. So my column I want to sort it by kind of looks like this: 0001110001001111001121100
Everytime it switches from 0 to 1 I want to make a new file and when it switches back to 0 thats the end. When there are only 0 nothing happens. A 2 means it´s paused so it should just take the 2 into the file as well. Is there any Node I could do this with? Or do you have any tips for me?
I hope you can understand what I would like to do.

Thanks!
B.

Hi @brittawi,

do you have an example file for the input?
It is quite hard to image what exactly is the task :thinking:

Could you maybe give an short example with a few input rows and what files you would expect?

1 Like

Hey @AnotherFraudUser,
sure, sorry for not making it clear enough!
So my input would kinda look like that:

so only the third column really matters. Every time it switches from 0 to 1 I want to make a new file. And if there´s a 2 it should just be included. It would be awesome if you would have a tip for me!

Thanks,
Britta

Hi @brittawi

This has some similarities with this Forum Post. But your question need some extra nodes to make it work. See the range_filering_2.knwf (66.3 KB)


gr. Hans

4 Likes

Hi @HansS,

thank you very much! This has helped me a lot! :slight_smile:

Britta

2 Likes

A little late - but here another solution :slight_smile:

  1. Use Rule Engine to turn all 0 -> 1
    And everything else to 0

  2. Use the Moving Aggregation to Sum up the new column (now you have your groups including the 0)

  3. Remove all 0 and write groups to file

workflow_group2.knar (21.9 KB)

*could you mark @HansS as solution - so this topic is closed :slight_smile:
(also likes for help is always appreciated - gotta collect those imaginary profile points :P)

4 Likes

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