CSV Reader

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Feb 12 09:33:03 EST 2008


En Tue, 12 Feb 2008 08:37:13 -0200, Mike P  
<michael.pearmain at tangozebra.com> escribi�:

> just saw i needed to change record.startswith to row.startswith
> but i get hte following traceback error
>
> Traceback (most recent call last):
>   File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework
> \scriptutils.py", line 310, in RunScript
>     exec codeObject in __main__.__dict__
>   File "Y:\technical\Research\E2C\Template_CSV\import CSV test.py",
> line 10, in <module>
>     if not start_line and row.startswith('Transaction ID'):
> AttributeError: 'list' object has no attribute 'startswith'

The csv reader doesn't return complete lines, but a list of fields for  
each line. If you want to check the first field, use:

if not start_line and row[0].startswith('Transaction ID'):

-- 
Gabriel Genellina




More information about the Python-list mailing list