Is anyone happy with csv module?
John Machin
sjmachin at lexicon.net
Tue Dec 11 16:37:10 EST 2007
On Dec 12, 6:14 am, "massimo s." <deviceran... at gmail.com> wrote:
> Hi,
>
> I'm struggling to use the python in-built csv module, and I must say
> I'm less than satisfied. Apart from being rather poorly documented,
Patches are welcome :-)
> I
> find it especially cumbersome to use,
Can you be more specific? What are you trying to do with it?
> and also rather limited.
What extra facilities do you think there should be?
> What I
> dislike more is that it seems working by *rows* instead than by
> *columns*.
Perhaps you'd better explain what you mean by "working by". Here's my
take on it:
A CSV file is organised such that each line of the file represents a
row, and the nth field in the line relates to the nth column, so it's
natural for any CSV reader/writer to work by rows. *Additional*
functionality e.g. to suck the file into a list of lists that could be
accessed easily by column index is possible, but it is well within the
competence of average Python programmers to write that themselves:
data = [row for row in csv.reader(......)]
...
whatever = data[row_index][col_index]
Accessing the data by columns *instead* of by rows would definitely
not be appreciated by people who are using the csv module to read
millions of lines of data.
>
> So I have some questions:
> 1) Is there a good tutorial, example collection etc. on the csv module
> that I'm missing?
AFAIK, no.
> 2) Is there an alternative csv read/write module?
Is your googler broken?
> 3) In case anyone else is as unhappy as me, and no tutorial etc.
> enlighten us, and no alternative is present, anyone is interested in
> an alternative csv module?
-1
> I'd like to write one if it is the case.
In what language?
Cheers,
John
More information about the Python-list
mailing list