column

Using a great command line toot column, it is easy to view the content of tab/comma separated files in a readable format.

Format CSV ',' as tabular output

column -t -s,' < your_file.csv

Format TSV :

column -ts $'\t' < your_file.tsv

Pipe the output to less

column -ts $'\t' < your_file | less

Put that in a script, for example ~/bin/tsvview

tsvview.sh
#!/bin/bash
 
set -o errexit
 
function show_usage {
  cat <<EOF
Usage: $0 [--help] [filename]
View a TSV file at the command line.
  --help        Show this help text.
  filename      CSV file to be viewed
EOF
  exit -1
}
 
if [ "$1" == "--help" -o "$1" == "" ]; then
  show_usage
fi
 
column -ts $'\t' < "$1" | less -#.3 -N -S

Make an alias alias tv='tsvview'

or a function

function tsv {
  column -ts $'\t' < "$1" | less -#.3 -N -S
}