| 1 |
======= |
| 2 |
csvlook |
| 3 |
======= |
| 4 |
|
| 5 |
Description |
| 6 |
=========== |
| 7 |
|
| 8 |
Renders a CSV to the command line in a Markdown-compatible, fixed-width format: |
| 9 |
|
| 10 |
.. code-block:: none |
| 11 |
|
| 12 |
usage: csvlook [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b] |
| 13 |
[-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-L LOCALE] |
| 14 |
[-S] [--blanks] [--null-value NULL_VALUES [NULL_VALUES ...]] |
| 15 |
[--date-format DATE_FORMAT] [--datetime-format DATETIME_FORMAT] |
| 16 |
[-H] [-K SKIP_LINES] [-v] [-l] [--zero] [-V] |
| 17 |
[--max-rows MAX_ROWS] [--max-columns MAX_COLUMNS] |
| 18 |
[--max-column-width MAX_COLUMN_WIDTH] |
| 19 |
[--max-precision MAX_PRECISION] [--no-number-ellipsis] |
| 20 |
[-y SNIFF_LIMIT] [-I] |
| 21 |
[FILE] |
| 22 |
|
| 23 |
Render a CSV file in the console as a Markdown-compatible, fixed-width table. |
| 24 |
|
| 25 |
positional arguments: |
| 26 |
FILE The CSV file to operate on. If omitted, will accept |
| 27 |
input as piped data via STDIN. |
| 28 |
|
| 29 |
optional arguments: |
| 30 |
-h, --help show this help message and exit |
| 31 |
--max-rows MAX_ROWS The maximum number of rows to display before |
| 32 |
truncating the data. |
| 33 |
--max-columns MAX_COLUMNS |
| 34 |
The maximum number of columns to display before |
| 35 |
truncating the data. |
| 36 |
--max-column-width MAX_COLUMN_WIDTH |
| 37 |
Truncate all columns to at most this width. The |
| 38 |
remainder will be replaced with ellipsis. |
| 39 |
--max-precision MAX_PRECISION |
| 40 |
The maximum number of decimal places to display. The |
| 41 |
remainder will be replaced with ellipsis. |
| 42 |
--no-number-ellipsis Disable the ellipsis if --max-precision is exceeded. |
| 43 |
-y SNIFF_LIMIT, --snifflimit SNIFF_LIMIT |
| 44 |
Limit CSV dialect sniffing to the specified number of |
| 45 |
bytes. Specify "0" to disable sniffing entirely, or |
| 46 |
"-1" to sniff the entire file. |
| 47 |
-I, --no-inference Disable type inference (and --locale, --date-format, |
| 48 |
--datetime-format, --no-leading-zeroes) when parsing |
| 49 |
the input. |
| 50 |
|
| 51 |
If a table is too wide to display properly try piping the output to ``less -S`` or truncating it using :doc:`csvcut`. |
| 52 |
|
| 53 |
If the table is too long, try filtering it down with grep or piping the output to ``less``. |
| 54 |
|
| 55 |
See also: :doc:`../common_arguments`. |
| 56 |
|
| 57 |
.. note:: |
| 58 |
|
| •59 |
The fractional part of a decimal numeral is always truncated. To control this truncation, use ``--no-inference`` along with ``--max-column-width``. |
| 60 |
|
| 61 |
Examples |
| 62 |
======== |
| 63 |
|
| 64 |
Basic use: |
| 65 |
|
| 66 |
.. code-block:: bash |
| 67 |
|
| 68 |
csvlook examples/testfixed_converted.csv |
| 69 |
|
| 70 |
This tool is especially useful as a final operation when piping through other tools: |
| 71 |
|
| 72 |
.. code-block:: bash |
| 73 |
|
| 74 |
csvcut -c 9,1 examples/realdata/FY09_EDU_Recipients_by_State.csv | csvlook |
| 75 |
|
| 76 |
If a data row contains more cells than the header row, csvlook will error. Use :doc:`csvclean` to remove such rows. |
| 77 |
|
| 78 |
To ignore the extra cells, instead: |
| 79 |
|
| 80 |
.. code-block:: bash |
| 81 |
|
| 82 |
csvcut -C "" examples/bad.csv | csvlook |
| 83 |
|
| 84 |
If these rows are at the top of the file (for example, copyright notices), you can skip the rows: |
| 85 |
|
| 86 |
.. code-block:: bash |
| 87 |
|
| 88 |
csvlook --skip-lines 1 examples/bad.csv |
| 89 |
|
| 90 |
This error can also occur if csvlook incorrectly deduces ("sniffs") the CSV format. To disable CSV sniffing, set :code:`--snifflimit 0` and then, if necessary, set the :code:`--delimiter` and :code:`--quotechar` options yourself. Or, set :code:`--snifflimit -1` to use the entire file as the sample, instead of the first 1024 bytes. |