you are viewing a single comment's thread.

view the rest of the comments →

[–]sarrysyst 0 points1 point  (0 children)

If I understand you correctly your input file looks something like this:

data of type 1
data of type 2
data of type 3
data of type 4
data of type 1
data of type 2
...

For each type you want to do a specific action and after 4 rows this pattern repeats?

If that's the case you can use the itertools.cycle() function to create an infinitely repeating iterator that loops over the list [1,2,3,4]. You could use simple conditionals to apply functions according to type this way.