Question on the "csv" library

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Aug 27 22:44:17 CEST 2009


vsoler wrote:
> On Aug 27, 9:42 pm, Andreas Waldenburger <use... at geekmail.INVALID>
> wrote:
>> On Thu, 27 Aug 2009 21:36:28 +0200 Andreas Waldenburger
>>
>> <use... at geekmail.INVALID> wrote:
>>> [snip]
>>> Might I humbly suggest
>>>>>> sheet = list(spamReader)  # ?
>> Oh, and while I'm humbly suggesting:
>>
>> spam_reader instead of spamReader or SpamReader or SpamrEadeR or
>> suchlike. Caps are "reserved" for classes.
>>
>> Not a necessity, of course. But it's the dialect around these parts.
>>
>> /W
>>
>> --
>> INVALID? DE!
> 
> Thank you for your answers. Let me however make some comments:
> 
> 1- the csv file was generated with Excel 2007; no prompts for what the
> separator should be; Excel has used ";" by default, without asking
> anything
I find this difficult to believe, but assuming that you are correct then 
use the delimiter=';' argument in the call to csv.reader.  See the csv 
module documentation section "Dialects and Formatting Parameters" for 
more information.
> 
> 2- about capitalisation, I used the var "spamReader" because I just
> copy/pasted from the official python site:
> 
>       http://docs.python.org/library/csv.html
> 
> 3- when I try
> 
>>>> sheet = [row for row in spamReader]
>>>> print sheet
> []
> 
> all I get is an empty list; something seems not to be working properly
> 
> Same result list: I get an empty list
> 
>      sheet = list(spamReader)
> 
> Thank you again for your help, which is highly appreciated.
> 
> Vicente Soler


-- 
Kindest regards.

Mark Lawrence.




More information about the Python-list mailing list