[Tutor] line number when reading files using csv module CORRECTION

Bob Gailer bgailer at alum.rpi.edu
Fri Oct 27 21:23:50 CEST 2006


Bob Gailer wrote:
> Duncan Gibson wrote:
>   
>> [snip]
>>     
>
>   
>> but I would like to record the line number in the file. 
>>   
>>     
> How about using enumerate():
>   
>>     for line_num, data in enumerate(reader):
>>         # print reader.line_num, data # SHOULD BE:
>>         print line_num, data
>>
>>
>>     
>   


-- 
Bob Gailer
510-978-4454



More information about the Tutor mailing list