(You can enlarge the video above using the controls or open it in a new tab by clicking here)

Visidata is an excellent program for handling CSVs in a command line environment. Good for quick operations to explore the data, such as sorting, cleaning, analysis, and even basic plotting.

pip install visidata

Can also

visidata file.csv

Can be shortned to vd in some environments. You can read a file without a header from the stdin, for example

cat file.csv | vd  --header=0 

Operations

  • q exits
  • ESC cancels
  • h, l, j, k for movements (as you would in Vim)
  • H, L, J, K for moving rows and columns in differnt directions
  • [ and ] sorts
  • - deletes column
  • d deletes row
  • Specifying type of column data @ date, # integer, $ currency, % float
  • ! designates a column as a key, e.g. to plot data against
  • . plots data. A key column should be speficied before, as well as the data type in the column(s) to be plotted
  • SHIFT+F frequency
  • SHIFT+I statistics
  • W pivot table
  • + aggregator
  • s t u select, toggle, and unselect current row
  • " start a new sheet with the selected row(s)
  • z+ displays result of aggregator over values in selectd rows for current column.
  • | select rows matching a regex
  • = evaluates a python expression, such as a condition a>1000. The above operation can then be used to select matching rows

More on this VisiData cheatsheet, and 10 Ways to Use VisiData.

It is not just CSVs

Anything that can be opened with pandas can be opened with visidata. So this includes excel and html, and even URIs. This is powerful: the capability of pandas and the speed and versatility of the command line.

For example, you can search for your engine oil from this table

vd https://www.gmdexos.com/brands/dexos1/index.html

it may prompt you to install lxml if you dont have it

pip install lxml