Skip to content

converting tabular data

converting a Markdown-formatted table to a TSV file

Attention

The Markdown-formatted table is expected to be a pipe table with a pipe character at the beginning of each line.

Note

  • foo.md represents an input text file containing a Markdown-formatted table.
  • bar.tsv represents an output TSV file.

Use sed -e 's/ *| */|/g' -e 's/[|]/\t/g' -e 's/\t//' -e '2d' foo.md > bar.tsv.

explanation

  • s/ *| */|/g removes spaces from around the pipe characters that separate table cells.
  • s/[|]/\t/g replaces pipe characters with tab characters.
  • s/\t// removes the first tab character on each line.
  • 2d removes the second line of the text file, the row of the table that indicates column alignment.

prior work

converting a Markdown-formatted table to an SQLite database table

Warning

SQLite values will be stored as text, so any HTML formatting will omitted.

Note

  • foo.html represents an input HTML file containing an HTML table.
  • bar.sqlite represents an output SQLite database file.

Convert the text file containing a Markdown-formatted table to an HTML file containing an HTML table, then use sqlitebiter -o bar.sqlite file foo.html.

licensing

No rights reserved: CC0 1.0.