[Zope] Comma delimited file and the re python object

Pavlos Christoforou pavlos@gaaros.msrc.sunysb.edu
Thu, 4 Nov 1999 10:13:41 -0500 (EST)


On Thu, 4 Nov 1999 ScherBi@BAM.com wrote:
> > > On Thu, 04 Nov 1999, Max M wrote:
> > > > I am trying to import a comma delimited ascii file via Python.
> > > >
> > > > naturally the pattern: , will not work as there might be 
> > a comma inside the
> > > > text.
> > > >
> > > > the pattern "," wont work either as there as the numbers 
> > are not enclosed in
> > > > quotes.

How about you first split the text by comma (string.split(line,',')). Then
you iterate over the elements and whenever an element has an odd number of
" (string.count(element,'"')%2) you join it with the following element.
Repeat the procedure until there are no more changes.

Haven't thought about it much though ...

Pavlos