ulthar.xyz > Repos

mdtable2csv

A very simple markdown table to CSV converter with no dependencies
About Files Commits git clone https://ulthar.xyz/repos/mdtable2csv/mdtable2csv.git

mdtable2csv/README.md

Download raw file: README.md

mdtable2csv.awk
===============

A simple AWK script for converting [Github-Flavoured Markdown](https://github.github.com/gfm/#tables-extension-)
tables to [RFC4180](https://datatracker.ietf.org/doc/html/rfc4180) CSV spreadsheets.  Consequently, it also has
reasonable support for [org-mode tables](https://orgmode.org/worg/org-syntax.html#Tables) and general plain-text
tables created using [Emacs' table.el](https://www.gnu.org/software/emacs/manual/html_node/emacs/Text-Based-Tables.html).  I've been using this
script with GAWK, but I believe it would work with other AWK
implementations as well.

## Installation and Usage

To install or uninstall just run `make install` or `make uninstall` as
root; `PREFIX` defaults to `/usr/local`.

Usage is dead simple with no options:

    mdtable2csv < table.md > spreadsheet.csv

Note that the input must *only* contain a table, bizarre and
undesirable things will happen if you try to convert an arbitrary
markdown file.  This is quite useful when used in conjunction with a
text-editor that lets you pipe the selected region into an external
program.

## Bugs and Limitations

- [Uneven rows](https://github.github.com/gfm/#example-204) are not supported and will result in mangled
  output.
- Forgoing leading or trailing pipes will result in columns being
  dropped
- We don't handle [colon alignment directives](https://github.github.com/gfm/#example-204) very well.
- Org-mode table delimeter rows that use `+` rather than `|` at cell
  boundaries are not supported.
Generated 2025-02-02 14:17:32 -0800 by RepoRat