split encloser

Tiller, Jason jtiller at sjm.com
Fri Apr 11 20:27:35 EDT 2003


Hi, "Aussie", :)

Now, to be totally honest, I kicked myself after Robin pointed out that you
can get a CSV add-on module for Python.  DOH!  ::sigh::  Of course something
like this is available - this is hardly the first-ever application of CSV
(or TSV or whatever)...

I apologize if the commented regex wasn't detailed enough to completely
explain its function.  If you have any  questions, don't hesitate to ask.  I
can tell that the base regex I described in my previous message doesn't meet
all the possible situations that a more sophisticated CSV module might.

If you're just interested in understanding regex'es for potential
application in your own scripts, the regex chapter in "Programming Perl" is
/very/ good, IMHO.  There's always Jeffrey Freidl's "Mastering Regular
Expressions" - all of the solid concepts are there, regardless of language.
I apologize that I can't really offer insight into Python-based regex
processing - I just haven't studied it well, and the Programming Python
(1.3) book that I have devotes only five or so pages to the entire topic
("Programming Perl"'s regex chapter is 70 pages, and "Mastering..." is 308
pages).  I would hope that the more modern "Programming Python" does a
better job...

However, for solving your particular problem, I encourage you to take a look
at the CSV module that Robin mentioned in his post.

Good luck!

---Jason

P.S. - I found documentation for the 'findall' method inside 'pre': "pydoc
pre" from the prompt displayed it.   The 'pre' module looks like Emacs ugly
"infinite backslash" notation (\\\\ just for a literal backslash!).
However, the 'sre' module uses the single-backslash notation, which is a lot
simpler.  I found documentation on python.org here:
http://www.python.org/doc/current/lib/node99.html that discusses the
'finditer' method.  Funny that I couldn't find it via PyDoc...

-----Original Message-----
From: aussie2010 at yahoo.com [mailto:aussie2010 at yahoo.com] 
Sent: Thursday, April 10, 2003 5:54 PM
To: python-list at python.org
Subject: Re: split encloser


Jason Tiller <jtiller at sjm.com> wrote in message
news:<mailman.1049417184.1536.python-list at python.org>...

> 
> Good luck!  I hope this pattern at least gives you a starting point
> for implementing the split() in Python.
> 
> ---Jason
> Sonos Handbell Ensemble

Jason, thanks a lot for the example and the explanation. I fired up
Perl and it worked like a charm. Now to try and understand it!  I
looked at stuff about Python regular expressions and there is
something called finditer and findall that might be useful for parsing
a string, but can't seem to find any documentation on them.
-- 
http://mail.python.org/mailman/listinfo/python-list


***************************** 
This communication may contain information that is proprietary, privileged,
confidential or legally exempt from disclosure.  If you are not a named
addressee, you are notified that you are not authorized to read, print,
retain, copy or disseminate this communication without the consent of the
sender and that doing so may be unlawful. If you have received this
communication in error, please notify the sender via return e-mail and
delete it from your computer. Thank you. St. Jude Medical, Inc. 
*****************************





More information about the Python-list mailing list