[Zope] Comma delimited file and the re python object

ScherBi@BAM.com ScherBi@BAM.com
Thu, 4 Nov 1999 09:37:15 -0500


Another idea you might try is to load the file into MS excel.  It has a
fairly nifty tool for loading delimited files.  Once you have it in excel,
you can export to something sane.  Other spreadsheets on other platforms may
be able to handle this as well.

Bill Scherer

> -----Original Message-----
> From: Martijn Faassen [mailto:m.faassen@vet.uu.nl]
> Sent: Thursday, November 04, 1999 8:48 AM
> Cc: Zope@zope.org
> Subject: Re: [Zope] Comma delimited file and the re python object
> 
> 
> Stephan Richter 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.
> > >
> > > There must be a simple pattern doing it right but I 
> cannot seem to figure it
> > > out myself.
> 
> > Look, then your datafile is corrupt. If you have commas in 
> the text fields then
> >  commas as seperator does not work. Period.
> 
> Not if all fields were delimited by double quotes ("). The algorithm
> would still be fairly simple then. But now numbers *aren't* 
> enclosed by
> quotes, which makes it rather more complicated to write, but 
> it's still
> possible.
> 
> This would get even more complicated if you do have escaped \" in
> strings. :)
> 
> > Choose another delimitor such as
> > TAB. I wrote a long while back a parser for these things. 
> It is trivial. Just a
> > few lines of code.
> 
> If you can choose your own datafile, that's best way to do it. If you
> already have a datafile that you can't control, you need to convert it
> to a tab delimited file first, for which you'd use Python, and you're
> stuck with the same problem. ;)
> 
> Anyway, if you need more help with Python I'd suggest looking in
> comp.lang.python. Possibly there are modules you can download that do
> this, too, at www.python.org.
> 
> Regards,
> 
> Martijn
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
>           No cross posts or HTML encoding!
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>