Can python extract org-mode tables from org documents?
2
votes
2
answers
221
views
I'm trying to write some python code that reads specified tables in org mode documents. For example, I have a file
~/foo.org
$ cat ~/foo.org
#+Title: Example Org Document
* Section One
Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.
#+TBLNAME: table1
| i | want | python | to |
|-------+---------+--------+--------|
| read | this | table | only |
| 1 | 3 | 2 | 4 |
|-------+---------+--------+--------|
| i | want | the | dashed |
| lines | ignored | by | python |
#+TBLNAME: table2
| i | don't | need | python | to |
|------+-------+-------+--------+----|
| read | this | table | 9 | 8 |
| 7 | 6 | 5 | 4 | 3 |
| 2 | 1 | 0 | 22 | 17 |
If my file were less complex, say
$ cat ~/bar.org
| i | want | python | to |
| read | this | table | only |
| 1 | 3 | 2 | 4 |
| i | want | the | dashed |
| lines | ignored | by | python |
then I could read the table into python with
import csv
csv.DictReader(open('~/bar.org'), delimiter='|')
Is there any way to parse my desired table from the more complicated ~/foo.org
?
Asked by Brian Fitzpatrick
(2907 rep)
May 11, 2016, 08:41 AM
Last activity: May 11, 2016, 07:50 PM
Last activity: May 11, 2016, 07:50 PM