Question on the "csv" library
usenot at geekmail.INVALID
Thu Aug 27 22:37:26 CEST 2009
On Thu, 27 Aug 2009 13:12:07 -0700 (PDT) vsoler
<vicente.soler at gmail.com> wrote:
> On Aug 27, 9:42 pm, Andreas Waldenburger <use... at geekmail.INVALID>
> [snip what I wrote]
> 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
Apparently it's possible, but it's a kludge
> 2- about capitalisation, I used the var "spamReader" because I just
> copy/pasted from the official python site:
Well, those hypocrites!
> 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.
I'm assuming you do that after you've iterated over the file before?
Because it did work in a previous post of yours.
Here's the deal: When you iterate over a file (or read from it in any
other manner) you "advance" in the file. After iteration, you're at the
end, of course. So iterating again yields silch.
Hmm ... don't know how that translates to a CSVReader. But I postulate
that it'l work on a fresh run.
More information about the Python-list