CSV Reader

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Feb 11 12:54:13 EST 2008


En Mon, 11 Feb 2008 14:41:54 -0200, Mike P  
<michael.pearmain at tangozebra.com> escribi�:

> CSV_Data = open(working_CSV)
> data = CSV_Data.readlines()
> flag=False
> for record in data:
>     if record.startswith('"Transaction ID"'):
>     [...]

Files are already iterable by lines. There is no need to use readlines(),  
and you can avoid the already menctioned potential slowdown problem. Just  
remove the data=CSV_data.readlines() line, and change that for statement  
to be:
for record in CSV_Data:

Reading the style guide may be beneficial:  
http://www.python.org/dev/peps/pep-0008/

-- 
Gabriel Genellina




More information about the Python-list mailing list