I tried using pyparsing to parse a CSV with: Commas between parenthesis (or brackets, etc): "a(1,2),b" should return the list ["a(1,2)","b"] Missing values: "a,b,,c," should return the list ['a','b','','c',''] I wor
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
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
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
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(
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
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
I am trying to install python-pyparsing onto my debian etch but running into issues when I run sudo apt-get install python-pyparsing_1.4.2-1.1_all.deb. Seems to give me this error here Reading package lists... Done Building dependency tree... Done W:
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
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
I'm a newbie in pyparsing and hope somebody can help me.The type of text I am trying to parse is of the following structure: I have key=value pairs in a line that can have one or more pairs. The values can be of many types such as string, int, float,
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
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
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
I have a file and parts of it looks like this: string 0 1 10 string with white space 0 10 30 string9 with number 9 10 20 50 string_ with underline 10 50 1 (string with parentese) 50 20 100 I need to parse each line, into something like: [[string, 0 ,
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
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
I'm having trouble getting setResultsName to work for me in this script, even when attempting to emulate examples given. I've looked to the documentation, consulted the author's book, and looked at forum examples. I've tried several variations, and I
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
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
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
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
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
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
I'd like to use pyparsing to parse an expression of the form: expr = '(gimme [some {nested [lists]}])', and get back a python list of the form: [[['gimme', ['some', ['nested', ['lists']]]]]]. Right now my grammar looks like this: nestedParens = neste
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
I have a string like the following: <118>date=2010-05-09,time=16:41:27,device_id=FE-2KA3F09000049,log_id=0400147717,log_part=00,type=statistics,subtype=n/a,pri=information,session_id=o49CedRc021772,from="
[email protected]"
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",
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
I saw on the Google App Engine documentation that http://www.antlr.org/ 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