The way to grab the first 10 lines of a text file could be done this way:
with open("myfile.txt") as myfile:
lines = [next(myfile).strip() for x in xrange(10)]
This will print the first 10 lines
But what if I only wanted lines 5-10? How would I do that? The file isn't small, it's going to be big. I need an efficient way to do this.
Thank you.