LINUX
Command-Line CSV Viewer
| Date Published: | |
| Last Modified: |
Create a new file called
csvin/usr/bin/(or in/usr/bin/local/if it exists in your distro):$ sudo vim /usr/bin/csvPaste the following code into the file (credit goes to Benjamin Noakes for this code):
#!/usr/bin/env bash # Author: Benjamin Oakes <hello@benjaminoakes.com> set -o errexit function show_usage { cat <<EOF Usage: $0 [--help] [filename] View a CSV 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 cat "$1" | column -s, -t | less -#2 -N -SExit vim (good luck!). Make this script executable:
$ sudo chmod +x ./csvAll done! As long as
/usr/bin/is on yourPATH, you should be able to nicely display CSV files in the command line with:$ csv my_file.csv
Related Content:
- mv (move)
- pandas
- March 2019 Updates
- A Comparison Of Serialization Formats
- Parsing Command-Line Arguments In Python
