Need help converting text to csv format
Tim Golden
mail at timgolden.me.uk
Fri Nov 21 12:00:44 EST 2008
Tim Chase wrote:
> yes, the CSV module has some wonderful stuff in it, and I regularly use
> it for *reading* CSV files. But for writing them, it's often just as
> fast (for my purposes) to simply code my 1st post's quickie as it is to
> scrounge in the docs/docstrings to remember how to let the CSV do the
> creation. But TimG is correct that using csv is the _right_ way to do
> it...gotta leave SOME work for the OP :)
Well I was going to point out that it's not that hard to remember
the functions, when I realised that I needn't have str ()-ed all
those values since the module does that for you. As it happens I
usually find it easy enough to remember.
But I think it's one of those
modules where you tend to think: why bother? it's only a
",".join (str (i) for i in f) away. Until you hit embedded quotes
or irregular delimiters. And you realise you've spawned a
monster genexp. And *then* you reach for "import csv" :)
TJG
More information about the Python-list
mailing list