VisiData
A very useful tool for data wrangling.
check this video: VisiData Lightning Demo at PyCascades 2018 - YouTube
$ pip install visidata
some quick test:
$ ps aux | vd
$ ls -l | vd -f fixed
To load another file, press o
and enter a filepath.
Press S
to access other loaded or derived sheets.
use <
and >
to move through a categorical column.
basic movement: h
, j
, k
and l
, add g
before to move all the way, for example gj
move to bottom
/
or ?
to search (slow?)
select rows
s
to select, u
to unselect, t
for toggling
add g
in front for all, for example gs
to select all
|
to select by regex, `‘ to unselect by regex rows matching in current column
add g
to select/unselect rows match any visible columns
,
select rows matching current cell in current column
g,
select rows matching currnet row in all visible columns
after selected rows
gz
to open a duplicate sheet with copies of the selected rows.
d
to delete andy
to yank the rowp
/P
to paste the row after/before current row
add g
to apply all, for example gd
to delete selected rows
sort rows
type the column:
#
: int%
: float@
: date~
: string$
: currency
[
or ]
sorts ascending/descending by current column
sort by multiple rows
- Press
!
on those columns to designate them as key columns. - Press
g[
org]
to sort.
columns
!
pins the current column on the left as a key column
H
or L
slides the current column one position to the left/right (add g
to move to all the way)
-
(hyphen) to hide the current column.
unhide:
C
to open columns sheet- move to the
0
cell,e
to change to a positive value q
to quit current sheet and return to original sheet
type a column:
#
: int%
: float@
: date~
: string$
: currency
type multiple columns:
C
to open columns sheets
to selectg~
to type selected columns tostring
typeq
to quit
split a column:
:
: adds new columns derived from splitting the current column at positions defined by a regex pattern.;
: adds new columns derived from pulling the contents of the current column which match the regex within capture groups.*
: followed by regex/substring replaces the text which matches the capture groups in regex with the contents of substring. substring may include backreferences (\1 etc).
concatenate columns:
- Type
=
followed byYear + '-' + Month + '-' + Day
- Set the type of the new derived column by pressing @ (date).
- Type ^ followed by Date to rename the column to Date.
aggregation:
- type the column
- select rows
- Type
g+
followed byavg
edit content
e
: edits contents of current cellge text
: sets contents of current column for selected rows to text
in edit mode:
Enter
: accepts inputCtrl-C
orEsc
: aborts inputCtrl-O
: opens external$EDITOR
to edit contentsCtrl-R
: reloads initial valueUp
orDown
: sets contents to previous/next in historyTab
orShift-Tab
: autocompletes input (when available)
rename columns:
^
: edits name of current columng^
: sets names of all unnamed visible columns to contents of selected rows (or current row)z^
: sets name of current column to contents of current cellgz^
: sets name of current column to combined contents of current column for selected rows
aggregation
+ aggregator
: adds aggregator to current column z+ aggregator
: displays result of aggregator over values in selected rows for current column
aggregators:
min
: smallest value in the groupmax
: largest value in the groupavg/mean
: average value of the groupmedian
: median value in the groupsum
: total summation of all numbers in the groupdistinct
: number of distinct values in the groupcount
: number of values in the groupkeymax
: key of the row with the largest value in the group
pivot table
- Press
!
on the independent variable to set it as a key column. - Press
+
on a second column to add an aggregrate. This configures which column is to be composed in relation to others. - Optional: Set the type for the column
- Press
W
on the dependent categorical variable to pivot on it.
F
to open the Frequency table.
graphs
.
(dot=plot) on that column
interact with graphs: http://visidata.org/docs/graph/