Improving my text processing script
Paul McGuire
ptmcg at austin.rr.com
Thu Sep 1 18:42:14 EDT 2005
Yes indeed, the real data often has surprising differences from the
simulations! :)
It turns out that pyparsing LineStart()'s are pretty fussy. Usually,
pyparsing is very forgiving about whitespace between expressions, but
it turns out that LineStart *must* be followed by the next expression,
with no leading whitespace.
Fortunately, your syntax is really quite forgiving, in that your
key-value pairs appear to always be an unquoted word (for the key) and
a quoted string (for the value). So you should be able to get this
working just by dropping the LineStart()'s from your expressions, that
is:
identLine=('Identifier'
+ prs.quotedString
+ prs.LineEnd()
).setResultsName('prog')
tableLine=('Value'
+ prs.quotedString
+ prs.LineEnd()
).setResultsName('table')
See if that works any better for you.
-- Paul
More information about the Python-list
mailing list