Skip to content Skip to sidebar Skip to footer

How To Use Pyparsing Group With Skipto For A File Parsing?

When I used pyparsing SkipTo together with other parser, the file parsing seems hang. unexpected = pp.SkipTo(pp.LineEnd())('unexpected*') rules = pp.Group(predefined_parser) | unex

Solution 1:

Short answer - change:

    | pp.SkipTo(pp.LineEnd(), include=True)

to:

    | pp.SkipTo(pp.LineEnd(), include=True).suppress()

When this is passed to Dict, it sees the two values created by SkipTo, so assumes it is the parsed results from a key-value pair, to be added into the cumulative dict. By suppressing this result, Dict gets an empty string, which it knows to ignore.

Post a Comment for "How To Use Pyparsing Group With Skipto For A File Parsing?"