Tim Golden wrote:
Tim Chase wrote:
 >>> qfields = ['"' + fld.strip() + '"' for fld in (num,desc,date)]
 >>> out = qfields.join(',')
Just a quick note here to prevent the confusion of the OP...this should be

  ','.join(qfields)

To be honest, it's so easy to use the stdlib csv module
that I'd always recommend that, especially as it covers
all those annoying corner cases with embedded commas and
quotes and stuff. And it's tested to hell and back.

[cedes point to TimG]

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 :)

too-many-tims-on-c.l.p'ly yers,

-tkc


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to