Search code examples
pythontextstructured-data

What structured text format is the best supported in Python?


This question may be seen as subjective, but I'd like to ask SO users which common structured textual data format is best supported in Python.

My initial choices are:

  • XML
  • JSON
  • and YAML

Which of these three is easiest to work with in Python (ie. has the best library support / performance) ... or is there another format that I haven't mentioned that is better supported in Python.

I cannot use a Python only format (e.g. Pickling) since interop is quite important, but the majority of the code that handles these files will be written in Python, so I'm keen to use a format that has the strongest support in Python.

CSV or fixed column text may also be viable for most use cases, however I'd prefer the flexibility of a more scalable format.

Thank you

Note

Regarding interop I will be generating these files initially from Ruby, using Builder, however Ruby will not be consuming these files again.


Solution

  • I would go with JSON, I mean YAML is awesome but interop with it is not that great.
    XML is just an ugly mess to look at and has too much fat.

    Python has a built-in JSON module since version 2.6.