How to loop through specific range of rows with Python csv reader?

前端 未结 3 1719
花落未央
花落未央 2021-01-18 00:15

How to loop through a specific range of rows with Python csv reader?

The following code loops through all rows:

with open(trainFile, \'rt\') as csvfi         


        
3条回答
  •  甜味超标
    2021-01-18 00:38

    Use islice, eg:

    rows_1_to_50 = itertools.islice(spamreader, 0, 50)
    for row in rows_1_to_50:
        pass
    

提交回复
热议问题