i, j = 10, 20
with open(trainFile, 'rt') as csvfile:
    spamreader = csv.reader(itertools.islice(csvfile, i, j + 1), delimiter=
        ' ', quotechar='|')
for row in spamreader:
    pass
How to loop through specific range of rows with Python csv reader?