Skip to main content

csv2md

Command line tool for converting CSV files into Markdown tables.

Installation

csv2md can be installed with pip from PyPI:

pip install csv2md

Or from source:

# type in the project directory
pip install .

Requirements

Usage

Generate Markdown table from CSV file:

csv2md table.csv

Generate Markdown table from TSV file:

csv2md -d $'\t' table.tsv

Generate Markdown tables from list of CSV files:

csv2md table1.csv table2.csv table3.csv

Generate Markdown table from standard input:

csv2md

You can also use it right inside your code, for example:

from csv2md.table import Table

with open("input.csv") as f:
    table = Table.parse_csv(f)

print(table.markdown())

Examples

Input file: simple.csv

year,make,model,description,price
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture «Extended Edition»","",4900.00
1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00

Output: csv2md simple.csv

| year | make  | model                      | description                       | price   |
| ---- | ----- | -------------------------- | --------------------------------- | ------- |
| 1997 | Ford  | E350                       | ac, abs, moon                     | 3000.00 |
| 1999 | Chevy | Venture «Extended Edition» |                                   | 4900.00 |
| 1996 | Jeep  | Grand Cherokee             | MUST SELL! air, moon roof, loaded | 4799.00 |

Markdown table:

year make model description price
1997 Ford E350 ac, abs, moon 3000.00
1999 Chevy Venture «Extended Edition» 4900.00
1996 Jeep Grand Cherokee MUST SELL! air, moon roof, loaded 4799.00

You can also specify delimiter, quotation characters and alignment (see Help).

Help

To view help run csv2md -h:

usage: csv2md [-h] [-d DELIMITER] [-q QUOTECHAR] [-C COLUMNS]
              [-c [CENTER_ALIGNED_COLUMNS ...]]
              [-r [RIGHT_ALIGNED_COLUMNS ...]] [-H]
              [CSV_FILE ...]

Parse CSV files into Markdown tables.

positional arguments:
  CSV_FILE              One or more CSV files to parse

options:
  -h, --help            show this help message and exit
  -d DELIMITER, --delimiter DELIMITER
                        delimiter character. Default is ','
  -q QUOTECHAR, --quotechar QUOTECHAR
                        quotation character. Default is '"'
  -C COLUMNS, --columns COLUMNS
                        comma-separated list of column indices or ranges (from
                        zero) to be processed, e.g. "0,3-5,7". Indices out of
                        range will be ignored
  -c [CENTER_ALIGNED_COLUMNS ...], --center-aligned-columns [CENTER_ALIGNED_COLUMNS ...]
                        column numbers with center alignment (from zero)
  -r [RIGHT_ALIGNED_COLUMNS ...], --right-aligned-columns [RIGHT_ALIGNED_COLUMNS ...]
                        column numbers with right alignment (from zero)
  -H, --no-header-row   specify that the input CSV file has no header row.
                        Will create default headers in Excel format
                        (a,b,c,...)

Running Tests

To run the tests, enter:

pytest . -v

Issue tracker

Please report any bugs and enhancement ideas using the csv2md issue tracker:

https://github.com/lzakharov/csv2md/issues

Feel free to also ask questions on the tracker.

Metadata

Release files for csv2md 1.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csv2md 1.8.0
File Size Uploaded Provenance Actions
csv2md-1.8.0.tar.gz 4.7 kB Without provenance Details for csv2md-1.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for csv2md 1.8.0
File Interpreter ABI Platform Actions
csv2md-1.8.0-py3-none-any.whl Python 3 none any Details for csv2md-1.8.0-py3-none-any.whl

Total release size: 11.1 kB

Release files / csv2md-1.8.0.tar.gz

Download URL csv2md-1.8.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cfb8dac854f0cb052741a940cc95b0bc8abbc47669f885c5d51b4b5d6fdcfe43
BLAKE2b-256 checksum
How to use checksums
ed245d9ad2075cc2528fec2d423b3ca14fce7025cc25cd805da6696d26b25d97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.14.8 Darwin/27.0.0

Release files / csv2md-1.8.0-py3-none-any.whl

Download URL csv2md-1.8.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14fe7af0b5e836bd15d512a46598f04787831905c007033a7c950dc07ef263fd
BLAKE2b-256 checksum
How to use checksums
295596127b89287bdbbd93de32a8d69447cc5853e4ff2d5b8abe5b0bcea4e533
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.14.8 Darwin/27.0.0

Security for csv2md 1.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page