View CSV files in a readable columnar format using Bash

13 Jul 2024

To view a CSV file in a more readable columnar format, the column command can be used combined with cat and tr.

Command to read CSV file

   cat file.csv | tr ',' '\t' | column -t -s $'\t' | less -S

Explanation

cat file.csv reads the content of the CSV file. tr ',' '\t' replaces commas with tabs.

column -t -s $'\t' formats the output into columns using tabs as the delimiter and finally, less -S pipes the formatted output into less for easy navigation, with the -S option enabling horizontal scrolling.

Replace file.csv with the actual CSV file.