- Notifications
You must be signed in to change notification settings - Fork1
command line utility for printing csv files
License
vegarsti/csvprint
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A command-line utility for pretty printing csv files and converting to other formats.
If Python 3 with the package manager pip is installed, doingpip3 install csvprint in your terminal should do the trick.
Withpipenv installed.
- Clone this repo
- Do
pipenv install pipenv shellpip install -e .
csvprint [filename] prints a formatted table iffilename is a comma separated file.
» cat imdb.csvTitle,Release Year,Estimated BudgetShawshank Redemption,1994,$25 000 000The Godfather,1972,$6 000 000The Godfather: Part II,1974,$13 000 000The Dark Knight,2008,$185 000 00012 Angry Men,1957,$350 000» csvprint imdb.csvTitle Release Year Estimated BudgetShawshank Redemption 1994 $25 000 000The Godfather 1972 $6 000 000The Godfather: Part II 1974 $13 000 000The Dark Knight 2008 $185 000 00012 Angry Men 1957 $350 000You can also pipe intocsvprint:
» cat imdb.csv | csvprintTitle Release Year Estimated BudgetShawshank Redemption 1994 $25 000 000The Godfather 1972 $6 000 000The Godfather: Part II 1974 $13 000 000The Dark Knight 2008 $185 000 00012 Angry Men 1957 $350 000| Command | Result |
|---|---|
-a | specify alignment (left or right) - see examples below |
-c | specify which columns to print |
-h | print help message |
--markdown | print as markdown |
--latex | print as latex table |
--numeric [c1:d1] [c2:d2] ... | specify decimal numbers for chosen numeric columns (c for column,d for digits) |
--header | add header decoration around the first line |
-s 'char' | file is delimited bychar (instead of comma),tab for tab |
-p [n] | add a padding ofn spaces for each column, on both sides |
-d [string] | specify the string to separate columns |
There are three options for specifying alignment. One can usel orr for aligning all cells to the left or right, respectively. One can also specify a distinct alignment option for each column. Then the number of options will need to match the number of columns.
» csvprint imdb.csv -a l r rTitle Release Year Estimated BudgetShawshank Redemption 1994 $25 000 000The Godfather 1972 $6 000 000The Godfather: Part II 1974 $13 000 000The Dark Knight 2008 $185 000 00012 Angry Men 1957 $350 000Markdown output also supports left and right alignment.
» csvprint examples/imdb.csv --markdown -a l r rTitle | Release Year | Estimated Budget:----------------------|-------------:|----------------:Shawshank Redemption | 1994 | $25 000 000The Godfather | 1972 | $6 000 000The Godfather: Part II | 1974 | $13 000 000The Dark Knight | 2008 | $185 000 00012 Angry Men | 1957 | $350 000When rendered as HTML, 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 |
» csvprint examples/numeric.csvmeasure1 measure21.2323 90001.299 9000001» csvprint examples/numeric.csv --numeric 1:1 2:1measure1 measure21.2 9000.01.3 9000001.0Runpytest while in the root directory of this repository.
About
command line utility for printing csv files
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.