Yes. Use itertools.islice :
from itertools import islice reader = csv.reader(csvfile) for row in islice(reader, 7, None): print row
This islice takes iterability, then the following positional arguments work just like your typical start-stop-stop step:
>>> x = list(range(14)) >>> x[7:None] [7, 8, 9, 10, 11, 12, 13] >>> x[7:] [7, 8, 9, 10, 11, 12, 13] >>> >>> list(islice(x, 7, None)) [7, 8, 9, 10, 11, 12, 13]
However, negative indexing is not allowed.
>>> list(islice(x, -1, None)) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Indices for islice() must be None or an integer: 0 <= x <= maxint. >>>
However, it is still very flexible, therefore, for example, for each line starting from the first (i.e. line with even numbers):
for row in islice(reader, None, None, 2): print row
Or each line starting with the second line (for example, an odd-numbered line):
for row in islice(reader, 1, None, 2): print row