# csv2md [![Build Status](https://app.travis-ci.com/lzakharov/csv2md.svg?branch=master)](https://app.travis-ci.com/lzakharov/csv2md) [![Coverage Status](https://codecov.io/gh/lzakharov/csv2md/branch/dev/graph/badge.svg)](https://codecov.io/gh/lzakharov/csv2md)
Command line tool for converting CSV files into Markdown tables.
## Installation
csv2md can be installed from source:
```commandline
# type in project directory
python setup.py install
```
Or with `pip` from PyPI:
```commandline
pip install csv2md
```
### Requirements
- Python 3.6 or later. See https://www.python.org/getit/
## Usage
Generate Markdown table from CSV file:
```commandline
csv2md table.csv
```
Generate Markdown table from TSV file:
```commandline
csv2md -d $'\t' table.tsv
```
Generate Markdown tables from list of CSV files:
```commandline
csv2md table1.csv table2.csv table3.csv
```
Generate Markdown table from standard input:
```commandline
csv2md
```
You can also use it right inside your code, for example:
```python
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](https://github.com/lzakharov/csv2md#help)).
## Help
To view help run `csv2md -h`:
```commandline
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:
```commandline
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](https://raw.githubusercontent.com/lzakharov/csv2md/master/LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/tddschn/csv2md",
"name": "csv2md-tddschn",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.12,<4.0",
"maintainer_email": "",
"keywords": "csv,markdown,convertor",
"author": "Teddy Xinyuan Chen",
"author_email": "45612704+tddschn@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/de/0a/f688f082432b8c648813d8600db394ab88dbd7c939da0655ef7de703a4e1/csv2md_tddschn-1.3.1.tar.gz",
"platform": null,
"description": "# csv2md [![Build Status](https://app.travis-ci.com/lzakharov/csv2md.svg?branch=master)](https://app.travis-ci.com/lzakharov/csv2md) [![Coverage Status](https://codecov.io/gh/lzakharov/csv2md/branch/dev/graph/badge.svg)](https://codecov.io/gh/lzakharov/csv2md)\n\nCommand line tool for converting CSV files into Markdown tables.\n\n## Installation\n\ncsv2md can be installed from source:\n\n```commandline\n# type in project directory\npython setup.py install\n```\n\nOr with `pip` from PyPI:\n```commandline\npip install csv2md\n```\n\n### Requirements\n\n- Python 3.6 or later. See https://www.python.org/getit/\n\n## Usage\n\nGenerate Markdown table from CSV file:\n\n```commandline\ncsv2md table.csv\n```\n\nGenerate Markdown table from TSV file:\n\n```commandline\ncsv2md -d $'\\t' table.tsv\n```\n\nGenerate Markdown tables from list of CSV files:\n\n```commandline\ncsv2md table1.csv table2.csv table3.csv\n```\n\nGenerate Markdown table from standard input:\n\n```commandline\ncsv2md\n```\n\nYou can also use it right inside your code, for example:\n\n```python\nfrom csv2md.table import Table\n\nwith open(\"input.csv\") as f:\n table = Table.parse_csv(f)\n\nprint(table.markdown())\n```\n\n### Examples\n\nInput file: `simple.csv`\n\n```\nyear,make,model,description,price\n1997,Ford,E350,\"ac, abs, moon\",3000.00\n1999,Chevy,\"Venture \u00abExtended Edition\u00bb\",\"\",4900.00\n1996,Jeep,Grand Cherokee,\"MUST SELL! air, moon roof, loaded\",4799.00\n```\n\nOutput: `csv2md simple.csv`\n\n```\n| year | make | model | description | price |\n| ---- | ----- | -------------------------- | --------------------------------- | ------- |\n| 1997 | Ford | E350 | ac, abs, moon | 3000.00 |\n| 1999 | Chevy | Venture \u00abExtended Edition\u00bb | | 4900.00 |\n| 1996 | Jeep | Grand Cherokee | MUST SELL! air, moon roof, loaded | 4799.00 |\n```\n\nMarkdown table:\n\n| year | make | model | description | price |\n| ---- | ----- | -------------------------- | --------------------------------- | ------- |\n| 1997 | Ford | E350 | ac, abs, moon | 3000.00 |\n| 1999 | Chevy | Venture \u00abExtended Edition\u00bb | | 4900.00 |\n| 1996 | Jeep | Grand Cherokee | MUST SELL! air, moon roof, loaded | 4799.00 |\n\nYou can also specify delimiter, quotation characters and alignment (see [Help](https://github.com/lzakharov/csv2md#help)). \n\n## Help\n\nTo view help run `csv2md -h`:\n\n```commandline\nusage: csv2md [-h] [-d DELIMITER] [-q QUOTECHAR] [-c [CENTER_ALIGNED_COLUMNS ...]] [-r [RIGHT_ALIGNED_COLUMNS ...]] [-H] [CSV_FILE ...]\n\nParse CSV files into Markdown tables.\n\npositional arguments:\n CSV_FILE One or more CSV files to parse\n\noptions:\n -h, --help show this help message and exit\n -d DELIMITER, --delimiter DELIMITER\n delimiter character. Default is ','\n -q QUOTECHAR, --quotechar QUOTECHAR\n quotation character. Default is '\"'\n -c [CENTER_ALIGNED_COLUMNS ...], --center-aligned-columns [CENTER_ALIGNED_COLUMNS ...]\n column numbers with center alignment (from zero)\n -r [RIGHT_ALIGNED_COLUMNS ...], --right-aligned-columns [RIGHT_ALIGNED_COLUMNS ...]\n column numbers with right alignment (from zero)\n -H, --no-header-row specify that the input CSV file has no header row. Will create default headers in Excel format (a,b,c,...)\n```\n\n## Running Tests\n\nTo run the tests, enter:\n\n```commandline\nnosetest\n```\n\n## Issue tracker\nPlease report any bugs and enhancement ideas using the csv2md issue tracker:\n\nhttps://github.com/lzakharov/csv2md/issues\n\nFeel free to also ask questions on the tracker.\n\n## License\n\nCopyright (c) 2023 Lev Zakharov. Licensed under [the MIT License](https://raw.githubusercontent.com/lzakharov/csv2md/master/LICENSE).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Command line tool for converting CSV files into Markdown tables.",
"version": "1.3.1",
"project_urls": {
"Bug Tracker": "https://github.com/tddschn/csv2md/issues",
"Homepage": "https://github.com/tddschn/csv2md",
"Repository": "https://github.com/tddschn/csv2md"
},
"split_keywords": [
"csv",
"markdown",
"convertor"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e4929fc9366b16bbbc67fbafbbb2bee2cc7b61d36350715055b5203befe6e603",
"md5": "4421e91c5f0a6f50efe993c39a3f375d",
"sha256": "de272f19dd3d992592b4c2e29843fdb380c09f33ed53bef447e474b5fb738a1f"
},
"downloads": -1,
"filename": "csv2md_tddschn-1.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4421e91c5f0a6f50efe993c39a3f375d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12,<4.0",
"size": 7070,
"upload_time": "2023-12-10T15:54:23",
"upload_time_iso_8601": "2023-12-10T15:54:23.343640Z",
"url": "https://files.pythonhosted.org/packages/e4/92/9fc9366b16bbbc67fbafbbb2bee2cc7b61d36350715055b5203befe6e603/csv2md_tddschn-1.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "de0af688f082432b8c648813d8600db394ab88dbd7c939da0655ef7de703a4e1",
"md5": "45529063007af01928c1e1a509caf950",
"sha256": "78dcaae826d49fea7aa091df4f3076f943962f03bca6eb05deab35c8cf896fa9"
},
"downloads": -1,
"filename": "csv2md_tddschn-1.3.1.tar.gz",
"has_sig": false,
"md5_digest": "45529063007af01928c1e1a509caf950",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12,<4.0",
"size": 5157,
"upload_time": "2023-12-10T15:54:25",
"upload_time_iso_8601": "2023-12-10T15:54:25.460423Z",
"url": "https://files.pythonhosted.org/packages/de/0a/f688f082432b8c648813d8600db394ab88dbd7c939da0655ef7de703a4e1/csv2md_tddschn-1.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-10 15:54:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tddschn",
"github_project": "csv2md",
"github_not_found": true,
"lcname": "csv2md-tddschn"
}