Skip to content

Commit

Permalink
docs: Add example to remove comment rows, #1238
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Apr 18, 2024
1 parent 0647faf commit d00ea20
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/scripts/csvgrep.rst
Expand Up @@ -71,8 +71,18 @@ Perform a case-insensitive search:
csvgrep -c 1 -r "(?i)illinois" examples/realdata/FY09_EDU_Recipients_by_State.csv
Remove comment rows:

.. code-block:: bash
printf "a,b\n1,2\n# a comment\n3,4" | csvgrep --invert-match -c1 -r '^#'
Get the indices of the columns that contain matching text (``\x1e`` is the `Record Separator (RS) character <https://en.wikipedia.org/wiki/C0_and_C1_control_codes#Field_separators>`_):

.. code-block::
csvgrep -m 22 -a -c 1- examples/realdata/FY09_EDU_Recipients_by_State.csv | csvformat -M $'\x1e' | xargs -d $'\x1e' -n1 sh -c 'echo $0 | csvcut -n' | grep 22
.. note::

This last example is not performant.

0 comments on commit d00ea20

Please sign in to comment.