csv to XML converter crash and burn

Julius Welby jwelby at waitrose.com
Sun Jul 8 09:17:25 EDT 2001


I just got all public spirited and posted this:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66003

It's a module for transforming csv to XML. It works fine for cvs strings
where no escaped commas or "" appear but.....

Unfortunately I now realise I didn't have a sufficient grasp of the csv
format. (I was under the impression that commas within csv data items were
commented out individually - i.e. item1, item ","2, item3 gives ['item1',
'item,2', 'item3'].

In fact the standard (?) appears to be to double-quote the entire item
containing the comma: item1,"item,2", item3
Also all " characters are escaped to "". (I know, I know, RTFM.)

It looks like handling csv text is more complicated than I thought.

Would anyone be interested in looking over the code (use the text source)
here?:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66003/index_txt

Is it worth trying to complete it as a stand-alone module, or should I scale
it down to a "parsed csv" to XML converter, accepting a list of already
parsed row strings?

If it's worth persevering, any help fixing it would be hugely welcomed.
Thanks in advance.





More information about the Python-list mailing list