4

The formatted data in file is similar to YAML and would like to create a grammer and parser for it. What is the easies way to do this in Python? Is there a tool that let you define a grammer for your data and parses according to the grammer?

P.S. I know the easier way to do this might be to change the data formate into JSON or other type but right now it can't be changed

1
  • 1
    pyparsing is a common answer. Commented Apr 3, 2012 at 20:18

3 Answers 3

3

Look into pyparsing. It's a pretty simple library, but it is also quite powerful.

Sign up to request clarification or add additional context in comments.

Comments

1

I have used PLY in conjunction with easyply earlier, and liked it - maybe, you will find it neat to use with your custom format.

Comments

0

Maybe you'd find funcparselib worthy. It has easy syntax both for tokenization and syntax definitions.

PyParsing is probably slower, but powerful and well-known.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.