* separated values

Skip Montanaro skip at pobox.com
Tue Jan 15 17:18:08 EST 2002

    Cliff> I've heard (I haven't looked for myself) that Dave's doesn't
    Cliff> support embedded newlines which is a big killer for many CSV
    Cliff> files...

I think it does the right thing in this regard.  Given this csv file:


running a slightly modified version of the test script that comes with the

    import sys
    import string
    import csv

    p = csv.parser()
    f = open(sys.argv[1])
    while 1:
        l = f.readline()
        if not l:
        r = p.parse(l)
        if r is not None:
            print r

produces this output:

    ['abc\ndef', '5', 'qwerty']


More information about the Python-list mailing list