csvtomd command line CSV TSV Markdown table

Converting CSV/TSV Data to Markdown Tables from Command Line Using csvtomd

In programming and computer work, there are many situations where you handle CSV-formatted files. This article introduces how to convert CSV(TSV) format files and CSV data to HTML-compatible Markdown tables from the command line using the 'csvtomd' package.

Shou Arisaka
2 min read
Oct 4, 2025

In programming and computer work, there are many situations where you handle CSV-formatted files. This article introduces how to convert CSV(TSV) format files and CSV data to HTML-compatible Markdown tables from the command line using the “csvtomd” package.

Image

sudo apt update ; sudo pip3 install csvtomd

mplewis/csvtomd: 📝📊 Convert your CSV files into Markdown tables.

Converting CSV to Markdown Tables

CSV like this:

_,リロード,ファイル削除,更新日順ソート,重さ,読み込みファイル制限
nomacs,不可,DEL,可能,軽い,不可
gwenview,F5,DEL,可能,重い,一部可能

Can be easily converted like this:

$ csvtomd hoge.csv
_         |  リロード  |  ファイル削除  |  更新日順ソート  |  重さ  |  読み込みファイル制限
----------|--------|----------|-----------|------|------------
nomacs    |  不可    |  DEL     |  可能       |  軽い  |  不可
gwenview  |  F5    |  DEL     |  可能       |  重い  |  一部可能

Converting TSV (or other delimiters) to Markdown Tables

When you want to convert TSV with tabs as delimiters like this:

_   リロード    ファイル削除  更新日順ソート 重さ  読み込みファイル制限
nomacs  不可  DEL 可能  軽い  不可
gwenview    F5  DEL 可能  重い  一部可能

csvtomd has an option to specify delimiters,

$ csvtomd -d "\t" fuga.csv
...
TypeError: "delimiter" must be a 1-character string

But you get a mysterious error. I don’t quite understand what it’s saying.

I expected this might happen, so I quickly came up with a solution. Use xsv.

BurntSushi/xsv: A fast CSV command line toolkit written in Rust.

The TSV data mentioned above can be converted to CSV using xsv.

$ cat fuga.csv  | xsv fmt -d "\t" --quote-always -t ","
"_","リロード","ファイル削除","更新日順ソート","重さ","読み込みファイル制限"
"nomacs","不可","DEL","可能","軽い","不可"
"gwenview","F5","DEL","可能","重い","一部可能"

Pass this from standard input like this:

Image

$ csvtomd <<< "$( cat hoge.csv  | xsv fmt -d "\t" --quote-always -t "," )"
_         |  リロード  |  ファイル削除  |  更新日順ソート  |  重さ  |  読み込みファイル制限
----------|--------|----------|-----------|------|------------
nomacs    |  不可    |  DEL     |  可能       |  軽い  |  不可
gwenview  |  F5    |  DEL     |  可能       |  重い  |  一部可能

Let’s verify the validity of the output Markdown.

Image

It renders properly.

Share this article

Shou Arisaka Oct 4, 2025

🔗 Copy Links