Re: simple text parser?

Discussion in 'Python' started by Irmen de Jong, Aug 17, 2003.

  1. Brandon J. Van Every wrote:

    > Can anyone recommend simple text parsers implemented in Python?


    You can use Python's own pickle mechanism to serialize almost
    any Python object(s). But you won't be able to read it back
    in if you also want to build it in another language such as C#
    that you mentioned.

    Perhaps you're better off using a simple .ini file structure,
    that should be *very* easy to parse in C# (I suspect it has .ini
    file parsing support built-in) and Python has the ConfigParser module.

    Or you could use a CSV (Comma Separated Values) file format,
    that is easily generated and parsed from Python's csv module
    and should also be easy to do from other languages.

    Alternatively you can go for something like this:

    ----------------
    item1=value1
    item2=value2
    item3=value3
    ....
    ----------------

    This is perhaps the easiest to create and parse, because in Python,
    you just execfile() or eval() the file back in. Warning: if somebody
    puts extra Python code in it, that will be executed.

    HTH,
    --Irmen de Jong
    Irmen de Jong, Aug 17, 2003
    #1
    1. Advertising

  2. Irmen de Jong wrote:
    > Brandon J. Van Every wrote:
    >
    >> Can anyone recommend simple text parsers implemented in Python?

    >
    > You can use Python's own pickle mechanism to serialize almost
    > any Python object(s). But you won't be able to read it back
    > in if you also want to build it in another language such as C#
    > that you mentioned.


    I don't care about C# interoperability. The Python and C# projects will be
    completely separate.

    > Or you could use a CSV (Comma Separated Values) file format,
    > that is easily generated and parsed from Python's csv module
    > and should also be easy to do from other languages.


    Will look into it.

    --
    Cheers, www.3DProgrammer.com
    Brandon Van Every Seattle, WA

    20% of the world is real.
    80% is gobbledygook we make up inside our own heads.
    Brandon J. Van Every, Aug 17, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil Hanna

    Re: simple text config file parser?

    Phil Hanna, Jul 1, 2003, in forum: Java
    Replies:
    0
    Views:
    3,183
    Phil Hanna
    Jul 1, 2003
  2. Bernd Oninger
    Replies:
    0
    Views:
    745
    Bernd Oninger
    Jun 9, 2004
  3. Michael Peuser

    Re: simple text parser?

    Michael Peuser, Aug 17, 2003, in forum: Python
    Replies:
    0
    Views:
    375
    Michael Peuser
    Aug 17, 2003
  4. Alex Martelli

    Re: simple text parser?

    Alex Martelli, Aug 17, 2003, in forum: Python
    Replies:
    3
    Views:
    368
    Brandon J. Van Every
    Aug 18, 2003
  5. mike b.
    Replies:
    3
    Views:
    154
    James Edward Gray II
    Jul 30, 2007
Loading...

Share This Page