pyparsing: analyze a sentence with special words

I am trying to write a program with pyparsing that parse all strings contains special words in it. I wrote following code, but it is not working: from pyparsing import * word = Word(alphas) sentence = OneOrMore(word) day = Literal("day") sentenc

Analysis of binary Stanford polygon files (PLY) with Pyparsing

For a larger project, I'm currently in the process of writing a Stanford polygon file (PLY) parser. The example at Github Gists is currently capable of parsing ASCII-format PLY files into a data abstraction Mesh. It also contains a description of the

NameError: the global name 'dot_parser' is not defined

I was playing with the decision tree algorithm and trying to plot the tree. However the IDE reported following error: Couldn't import dot_parser, loading of dot files will not be possible. <class 'pandas.core.frame.DataFrame'> Traceback (most recent

Pyparsing, Python 3 and the Unicode Byte Command Mark

I have a text file which is UTF-8 encoded with the byte order mark present - that is, the first few bytes are EF BB BF 0D 0A 4D... (it's a Visual Studio solution file produced by VS 2013). I'm trying to parse this with PyParsing, using the parseFile(

choose the analyzer based on previous results

I'm parsing several outputs and these files have two different headers: header1 = " MO EIGENVALUES, MO OCCUPATION NUMBERS, AND CARTESIAN MO EIGENVECTORS AFTER SCF STEP -1" header2 = "MO EIGENVALUES, MO OCCUPATION NUMBERS, AND SPHERICAL MO E

Pyparsing: How to insert new elements into a ParseResult

I developing a pyparsing grammar which must to insert new tokens to the ouput. This tokens are not from the original input. Ex.: Input: '/* foo bar*/' Ouput: ['comment', '/* foo bar*/'] How can I add elements to the parser output if this elements are

Pyparsing name string in quotation marks

I have a string that can contain something like this: s = "'Mark, Bob','John'" What is the best way to parse this into 3 strings? I am really new to pyparsing, and I am afraid that I don't understand it too well (edit) I am sorry, I was not very

A pypars grammar for the analysis of titles containing 'v.'

I am thinking about parsing titles of the form <left part> v. <right part> by using pyparsing. The left part can be names with alphanumeric characters including utf-8 characters and punctuation. Even v. itself is allowed in the left part. Howe

How to make PyParsing recognize \ x exhausts?

I want to use PyParsing to parse BNF-based rules. A rule may look like: A -> 'You can use \xABCD to display hexadecimal numbers' Where A is a nonterminal symbol. The assignment operand is '->'. The last item is a quoted string. I use PyParsing in th

Does Pyparsing support contextual grammars?

Forgive me if I have the incorrect terminology; perhaps just getting the "right" words to describe what I want is enough for me to find the answer on my own. I am working on a parser for ODL (Object Description Language), an arcane language that

Parsing Names with Pyparsing

I have a file of names and ages, john 25 bob 30 john bob 35 Here is what I have so far from pyparsing import * data = ''' john 25 bob 30 john bob 35 ''' name = Word(alphas + Optional(' ') + alphas) rowData = Group(name + Suppress(White(" ")) + W

Python pyparsing string: A, B, B, B, A, B, B, B *

I have a crazy problem. I am trying to use pyparsing to parse something like this: (dots are unimportant suppressed text) ...... A B ....... B ....... ...... A B ....... B ....... What I need is something like this: (to connect A and B element into o

pass the user-defined argument to setParseAction in pyparsing

I have something like following (simplified version) class ParseClass(object): def __init__(self, tokens): # do some processing on tokens expr = Word().setParseAction(ParseClass) Is there any way to send some user-defined argument to init function of

The setParseAction function of Pyparsing receives no arguments

I'm trying to parse a simple key = value query language. I've actually accomplished it with a huge monstrosity parser that I then make a second pass through to clean up the parse tree. What I'd like to do is make a clean parse from the bottom up, whi

Analysis of nested function calls using pyparsing

I'm trying to use pyparsing to parse function calls in the form: f(x, y) That's easy. But since it's a recursive-descent parser, it should also be easy to parse: f(g(x), y) That's what I can't get. Here's a boiled-down example: from pyparsing import

Print a result tree pyparsing

I am using pyparsing to parse a hex string and I am searching for an automatic way of print the parser tree. A near approach is command dump but it print a lot of duplicated info. For example: from pyparsing import * #Word, Optional, OneOrMore, Group

Pyparsing SetParseAction disorder

I am a new-bee to pyparsing I am trying to experiment with setParseAction but it is not being called sometimes. Here is the code def fun(): comdty_tok = StringStart() + Word(alphas) + StringEnd() comdty_tok.setParseAction(call_back) comdty_tok.leaveW

How to extract specific information from an output in Python

So I have a code that gives an output, and what I need to do is pull the information out in between the commas, assign them to a variable that changes dynamically when called... here is my code: import re data_directory = 'Z:/Blender_Roto/' data_file

PyParsing Statement

This is going to end up being really simple, but I'm trying to match one of the two patterns: "GET /ligonier-broadcast-media/mp3/rym20110421.mp3 HTTP/1.1" or - I've tried something like this: key = Word(alphas + nums + "/" + "-&qu

what after pyparsing?

I have a huge grammar developed for pyparsing as part of a large, pure Python application. I have reached the limit of performance tweaking and I'm at the point where the diminishing returns make me start to look elsewhere. Yes, I think I know most o

pyparsing question

This code works: from pyparsing import * zipRE = "\d{5}(?:[-\s]\d{4})?" fooRE = "^\!\s+.*" zipcode = Regex( zipRE ) foo = Regex( fooRE ) query = ( zipcode | foo ) tests = [ "80517", "C6H5OH", "90001-3234",

PyParsing simple language expressions

I'm trying to write something that will parse some code. I'm able to successfully parse foo(spam) and spam+eggs, but foo(spam+eggs) (recursive descent? my terminology from compilers is a bit rusty) fails. I have the following code: from pyparsing_py3

How can I configure PyParsing on Google App Engine?

I saw on the Google App Engine documentation that Antlr3 is used as the parsing third party library. But from what I know Pyparsing seems to be the easier to use and I am only aiming to parse some simple syntax. Is there an alte