I have a text file that looks a bit like this:
line 1
line 2
line 3
line 4
line 1
line 2
line 3
line 4
(etc)
At every line 1
I want to perform a specific operation, and at every line 2
a different operation, etc. The pattern of line repetition (including blanks) holds throughout the document, so currently I just have a counter that resets at every blank line and a bunch of if
statements:
if counter == 1:
this(line)
elif counter == 2:
that(line)
elif etc
My question, is there a more efficient, more Pythonic way of doing this?
Thanks!