I am reading xyz trajectory files a lot. These files are structured in a way, that information corresponding to a time frame is stored in N lines.
I would like to write an iterator similar to:
file=open(...)
for line in file:
analyze(line)
but reading N line at once:
file=Myopen(...,N=n)
for Nlines in file:
analyze(Nlines)
Since the files are huge, I do not want to read the whole into memory, but the purpose is not to gain efficiency but to make a clean and reuseable code. Of course, one could check the index%N==0, and analyze when it is true, but I am a bit sick of writing that few lines over, and over, and over....
Comments and answers are more than appreciated!