ASCII delimited files

Darrell news at dorb.com
Wed Nov 10 23:14:38 EST 1999


If comma delimited files are what your after then I have some 'C' code for
you.

This came up on the Zope list a week ago and there was a regular expression
solution.
Li Dongfeng  "Re: [Zope] Comma delimited file and the re python object"

"""
Tests for splitQuote.pyd
"""
from splitQuote import *
import time

txt=r'''
"Bond, James", 13, 45
'That\'s "absolutely","possible."', 1999, 8, 30
"""now"",""is"\'"",the,555,"""time"""
'''
#"""

print split.__doc__
buf=txt*2
print 'Buf len:',len(buf)
t1=time.time()
l=split(buf)
print 'Num records:',len(l)
print "Time: %.2f"%(time.time()-t1)
for x in range(4):
    print l[x]
valid=[['Bond, James', '13', '45'],
['That\\\'s "absolutely","possible."', '1999', '8', '30'],
['""now"",""is"\\\'"', 'the', '555', '""time""'],
['Bond, James', '13', '45'],
['That\\\'s "absolutely","possible."', '1999', '8', '30'],
['""now"",""is"\\\'"', 'the', '555', '""time""']]
assert(l==valid)

--
--Darrell

Roger Irwin <irwin at mail.com> wrote in message
news:942231502.1914033961 at news.interbusiness.it...
> Is there any function or module available for parsing ASCII delimited
files,
> before I go and re-invent the wheel writing my own.
>
> BTW, I know it is simple to do, but I was thinking along the lines that a
> 'standard' could easily be substituted for a C version for large files.
>







More information about the Python-list mailing list