Pretty-printer for csv files, including in Markdown format
Project description
Command-line utility for pretty printing csv files.
Installation
If Python 3 with the package manager pip is installed, doing pip3 install csvprint in your terminal should do the trick.
Usage
csvprint [filename] prints a formatted table if filename is a comma separated file.
» csvprint examples/imdb.csv Title Release Year Estimated Budget Shawshank Redemption 1994 $25 000 000 The Godfather 1972 $6 000 000 The Godfather: Part II 1974 $13 000 000 The Dark Knight 2008 $185 000 000 12 Angry Men 1957 $350 000
You can also pipe output from other programs to csvprint to format the output:
» cat examples/imdb.csv | csvprint Title Release Year Estimated Budget Shawshank Redemption 1994 $25 000 000 The Godfather 1972 $6 000 000 The Godfather: Part II 1974 $13 000 000 The Dark Knight 2008 $185 000 000 12 Angry Men 1957 $350 000
Options
Command |
Result |
---|---|
--markdown |
print as markdown table |
--header |
add header decoration around the first line |
-p [n] |
add a padding of n spaces for each column, on both sides |
-s 'char' |
file is delimited by char (instead of comma), tab for tab |
-d [string] |
specify the string to separate columns |
-j |
specify justification (left or right) - see examples below |
-h |
print help message |
Justification example
There are three options for specifying justification. One can use l or r for justifying all cells to the left or right, respectively. One can also specify a distinct justification option for each column. Then the number of options will need to match the number of columns.
» csvprint examples/imdb.csv -j l r r Title Release Year Estimated Budget Shawshank Redemption 1994 $25 000 000 The Godfather 1972 $6 000 000 The Godfather: Part II 1974 $13 000 000 The Dark Knight 2008 $185 000 000 12 Angry Men 1957 $350 000
Markdown example
Markdown output also supports left and right justification (not centered for now).
» csvprint examples/imdb.csv --markdown Title | Release Year | Estimated Budget :----------------------|:-------------|:---------------- Shawshank Redemption | 1994 | $25 000 000 The Godfather | 1972 | $6 000 000 The Godfather: Part II | 1974 | $13 000 000 The Dark Knight | 2008 | $185 000 000 12 Angry Men | 1957 | $350 000
When rendered as markdown, this looks like
Title |
Release Year |
Estimated Budget |
---|---|---|
Shawshank Redemption |
1994 |
$25 000 000 |
The Godfather |
1972 |
$6 000 000 |
The Godfather: Part II |
1974 |
$13 000 000 |
The Dark Knight |
2008 |
$185 000 000 |
12 Angry Men |
1957 |
$350 000 |
Testing
Run pytest while in the root directory of this repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for csvprint-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 357d884d6e672a55b0aecb6ff21df17f7a2c2b0729f0e73250d2b7700d0020a6 |
|
MD5 | 2c38744a13f34a8373bdc280592f6b78 |
|
BLAKE2b-256 | 432e8812422324e849cf13d54b08a89e43f951ba603aecdb5c0d1d83a5c8e7a0 |