New answers tagged

0

The easiest thing to do if you control the input format you expect is to read the entire file into python, extract with a regular expression the table of interest, then pass this to csv: import csv, re data = open("foo.org").read() mo = re.search("TBLNAME: table1\n.*?\n(\n|$)", data, re.S) mytable = mo.group(0) d = csv.DictReader(mytable.splitlines(), ...


0

You could write a Python function that reads and adds the lines whose first and last character is a '|' to a table (which could be a list object where each item is one line of the table). If you have several tables, a line not beginning with '|' is the hint for 'end-of-table'.



Top 50 recent answers are included