<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> man, now that is beautifully done.  Paul, I wish I knew about pyparsing
> a while ago. I could have used it in a few projects. :)
>
Thanks for the compliment!  I'll be the first to admit that pyparsing can be
a bit persnickety in some applications, especially when you have to trap on
end-of-line, or have some columnar-dependent syntax.  pyparsing really works
best with data that has some syntactic structure to it, but is not
whitespace sensitive (pyparsing's default behavior is to skip over
whitespace).  I don't recommend it when the data is well-formed - regexp's
or even just string.split() will blow it away from a performance (and
simplicity) standpoint.  For instance, if the OP knew that all his data was
itemId, tapeId, recordNum, startTime, endTime, comment, he could have most
easily parsed it with

item, tape, recordNum, startTime, endTime, comment = dataline.split(None,5)

It's just those optional and variable-formatted fields that getcha. :)

-- Paul

pyparsing can be downloaded at http://pyparsing.sourceforge.net.


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to