I need to read only every second line of the file (which is very large), so I do not want to use it readlines(). I'm not sure how to implement an iterator, so any suggestions are welcome. One possibility is to call next () twice. Not very attractive.
with open(pth_file, 'rw') as pth:
pth.next()
for i,row in enumerate(pth):
pth.next()
Or create your own iterator like
for i, row in enumerate(pth):
if i...
source
share