4

I often use python scripts to parse information stored in many of my org tables. To get python to read these tables I have a script that exports specific tables from a specified org document to csv. I then use

csv.DictReader(open('/path/to/csv/table.csv'))

to parse the information with python.

It recently dawned on me that python could (more or less) read the org tables themselves with something like

csv.DictReader(open('/path/to/org/doc.org'), delimiter='|')

but this would require doc.org to consist solely of an org table. I'm curious if anyone has come across a tool for python that can search an org document for a specified table and parse the table as if it were a csv file. Does such a tool exist?

1 Answer 1

2

One solution is to have a Python Babel block in the Org document that parses the table and writes a CSV. You can then call that Babel block from outside Org (using emacsclient?) to produce the CSV.

Or, not surprisingly, John Kitchen has solved this closer to the way you want: http://kitchingroup.cheme.cmu.edu/blog/2014/08/11/Using-org-mode-outside-of-Emacs-sort-of/

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.