Is there the equivalent of to_markdown to read data?
You can read markdown tables (or any structured text table) with the pandas read_table
function:
Let's create a sample markdown table:
pd.DataFrame({"a": [0, 1], "b":[2, 3]}).to_markdown()
| | a | b ||---:|----:|----:|| 0 | 0 | 2 || 1 | 1 | 3 |
As you can see, this is just a structured text table where the delimiters are pipes, there's a lot of whitespace, there are null columns on the left-most and right-most, and there's a header underline that must be dropped.
pd # Read a markdown file, getting the header from the first row and inex from the second column .read_table('df.md', sep="|", header=0, index_col=1, skipinitialspace=True) # Drop the left-most and right-most null columns .dropna(axis=1, how='all') # Drop the header underline row .iloc[1:] a b0 0 21 1 3