-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,140 additions
and
830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
__title__ = "csvmedkit" | ||
__description__ = """The unofficial extended family of csvkit, i.e. even more tools for command-line data parsing and wrangling""" | ||
__url__ = "https://github.com/dannguyen/csvmedkit" | ||
__version__ = "0.0.9.13" | ||
__version__ = "0.0.9.14" | ||
__short_version__ = __version__.split("-")[0] | ||
__author__ = "Dan Nguyen" | ||
__author_email__ = "dansonguyen@gmail.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
|
||
|
||
How it compares to existing tools | ||
================================= | ||
|
||
|
||
Compared to csvkit's``csvlook`` | ||
------------------------------- | ||
|
||
|
||
`csvlook <https://csvkit.readthedocs.io/en/latest/scripts/csvlook.html>`_ doesn't pretty-format multi-line fields, and can also result in very wide tables without ``--max-column-width``:: | ||
|
||
$ csvlook examples/hamlet.csv --max-column-width 50 | ||
|
||
| act | scene | speaker | lines | | ||
| --- | ----- | -------- | -------------------------------------------------- | | ||
| 1 | 5 | Horatio | Propose the oath, my lord. | | ||
| 1 | 5 | Hamlet | Never to speak of this that you have seen, | ||
Swea... | | ||
| 1 | 5 | Ghost | [Beneath] Swear. | | ||
| 3 | 4 | Gertrude | O, speak to me no more; | ||
These words, like dagge... | | ||
| 4 | 7 | Laertes | Know you the hand? | | ||
|
||
|
||
Compared to ``xsv flatten`` | ||
--------------------------- | ||
|
||
`xsv flatten <https://github.com/BurntSushi/xsv#available-commands>`_ does do auto-wrapping of long entries, but doesn't produce tableized output:: | ||
|
||
$ xsv flatten examples/hamlet.csv | ||
|
||
act 1 | ||
scene 5 | ||
speaker Horatio | ||
lines Propose the oath, my lord. | ||
# | ||
act 1 | ||
scene 5 | ||
speaker Hamlet | ||
lines Never to speak of this that you have seen, | ||
Swear by my sword. | ||
# | ||
act 1 | ||
scene 5 | ||
speaker Ghost | ||
lines [Beneath] Swear. | ||
# | ||
act 3 | ||
scene 4 | ||
speaker Gertrude | ||
lines O, speak to me no more; | ||
These words, like daggers, enter in mine ears; | ||
No more, sweet Hamlet! | ||
# | ||
act 4 | ||
scene 7 | ||
speaker Laertes | ||
lines Know you the hand? | ||
|
||
|
||
Compared to ``tabulate`` | ||
------------------------ | ||
|
||
`python-tabulate <https://pypi.org/project/tabulate/>`_ is a command-line tool for producing a variety of tabular outputs, including ``rst``, ``grid``, and ``html`` formats. However, it does not handle multi-line fields well. Nor does it natively handle the CSV format, e.g. double-quoted values that contain commas, hence, the use of csvkit's `csvformat <https://csvkit.readthedocs.io/en/latest/scripts/csvformat.html>`_ to change delimiters to ``\t`` in the example below:: | ||
|
||
|
||
|
||
$ csvformat -T examples/hamlet.csv | tabulate -f grid -1 -s '\t' | ||
|
||
+------------------------------------------------+---------+-----------+---------------------------------------------+ | ||
| act | scene | speaker | lines | | ||
+================================================+=========+===========+=============================================+ | ||
| 1 | 5 | Horatio | Propose the oath, my lord. | | ||
+------------------------------------------------+---------+-----------+---------------------------------------------+ | ||
| 1 | 5 | Hamlet | "Never to speak of this that you have seen, | | ||
+------------------------------------------------+---------+-----------+---------------------------------------------+ | ||
| Swear by my sword." | | | | | ||
+------------------------------------------------+---------+-----------+---------------------------------------------+ | ||
| 1 | 5 | Ghost | [Beneath] Swear. | | ||
+------------------------------------------------+---------+-----------+---------------------------------------------+ | ||
| 3 | 4 | Gertrude | "O, speak to me no more; | | ||
+------------------------------------------------+---------+-----------+---------------------------------------------+ | ||
| These words, like daggers, enter in mine ears; | | | | | ||
+------------------------------------------------+---------+-----------+---------------------------------------------+ | ||
| No more, sweet Hamlet!" | | | | | ||
+------------------------------------------------+---------+-----------+---------------------------------------------+ | ||
| 4 | 7 | Laertes | Know you the hand? | | ||
+------------------------------------------------+---------+-----------+---------------------------------------------+ | ||
|
||
|
||
That said, if you like ``tabulate``'s table-formatting options, such as ``-f grid``, you can pipe :command:`csvflatten` (and :command:`csvformat` to convert to tab-delimiters) into ``tabulate`` like so:: | ||
|
||
|
||
$ csvflatten --eor 'none' examples/hamlet.csv | csvformat -T \ | ||
tabulate -f grid -1 -s '\t' | ||
|
||
+---------+------------------------------------------------+ | ||
| field | value | | ||
+=========+================================================+ | ||
| act | 1 | | ||
+---------+------------------------------------------------+ | ||
| scene | 5 | | ||
+---------+------------------------------------------------+ | ||
| speaker | Horatio | | ||
+---------+------------------------------------------------+ | ||
| lines | Propose the oath, my lord. | | ||
+---------+------------------------------------------------+ | ||
| act | 1 | | ||
+---------+------------------------------------------------+ | ||
| scene | 5 | | ||
+---------+------------------------------------------------+ | ||
| speaker | Hamlet | | ||
+---------+------------------------------------------------+ | ||
| lines | Never to speak of this that you have seen, | | ||
+---------+------------------------------------------------+ | ||
| | Swear by my sword. | | ||
+---------+------------------------------------------------+ | ||
| act | 1 | | ||
+---------+------------------------------------------------+ | ||
| scene | 5 | | ||
+---------+------------------------------------------------+ | ||
| speaker | Ghost | | ||
+---------+------------------------------------------------+ | ||
| lines | [Beneath] Swear. | | ||
+---------+------------------------------------------------+ | ||
| act | 3 | | ||
+---------+------------------------------------------------+ | ||
| scene | 4 | | ||
+---------+------------------------------------------------+ | ||
| speaker | Gertrude | | ||
+---------+------------------------------------------------+ | ||
| lines | O, speak to me no more; | | ||
+---------+------------------------------------------------+ | ||
| | These words, like daggers, enter in mine ears; | | ||
+---------+------------------------------------------------+ | ||
| | No more, sweet Hamlet! | | ||
+---------+------------------------------------------------+ | ||
| act | 4 | | ||
+---------+------------------------------------------------+ | ||
| scene | 7 | | ||
+---------+------------------------------------------------+ | ||
| speaker | Laertes | | ||
+---------+------------------------------------------------+ | ||
| lines | Know you the hand? | | ||
+---------+------------------------------------------------+ | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.