Skip to main content

csv2md Build Status Coverage Status

Command line tool for converting CSV files into Markdown tables.

Installation

csv2md can be installed from source:

# type in project directory
python setup.py install

Or with pip from PyPI:

pip install csv2md

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 [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 [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:

nosetest

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.

License

Copyright (c) 2023 Lev Zakharov. Licensed under the MIT License.

Metadata

Release files for csv2md-tddschn 1.3.1

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-tddschn 1.3.1
File Size Uploaded
csv2md_tddschn-1.3.1.tar.gz 5.2 kB Details

Built distribution (wheel)

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

Total release size: 12.2 kB

Release files / csv2md_tddschn-1.3.1.tar.gz

Download URL csv2md_tddschn-1.3.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
78dcaae826d49fea7aa091df4f3076f943962f03bca6eb05deab35c8cf896fa9
BLAKE2b-256 checksum
How to use checksums
de0af688f082432b8c648813d8600db394ab88dbd7c939da0655ef7de703a4e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.0 Darwin/23.1.0

Release files / csv2md_tddschn-1.3.1-py3-none-any.whl

Download URL csv2md_tddschn-1.3.1-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de272f19dd3d992592b4c2e29843fdb380c09f33ed53bef447e474b5fb738a1f
BLAKE2b-256 checksum
How to use checksums
e4929fc9366b16bbbc67fbafbbb2bee2cc7b61d36350715055b5203befe6e603
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.0 Darwin/23.1.0

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

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