View tabular file such as CSV from command line

Matheus Mello
Matheus Mello
September 2, 2023
Cover Image for View tabular file such as CSV from command line

How to View Tabular Files (such as CSV) from the Command Line 😎💻

So, you want to view a tabular file (like CSV) from the command line, eh? You're in luck! In this guide, we'll walk you through some common issues, provide easy solutions, and spice things up with a compelling call-to-action. Let's dive right in! 🏊‍♂️📚

The Problem: Command-Line CSV Viewing on Linux/OS X 😫

You're tired of squinting at plain-text CSV files in your terminal. Opening them in Calc or Excel is overkill and just not what you need. You want something like less, but with properly spaced columns and the ability to scroll both horizontally and vertically. So, how do you go about achieving this magic? 🧙‍♂️✨

The Solution: Meet csvkit 🌟📑

Enter csvkit - a fantastic tool that will revolutionize the way you view tabular files from the command line. 🎉

First things first, let's install csvkit. If you're using Linux, open your terminal and run the following command:

$ sudo apt-get install csvkit

If you're on macOS, use Homebrew:

$ brew install csvkit

Once installed, you can unleash the power of csvkit on your tabular files, including CSVs. 🚀

To view a CSV file in a pretty, human-friendly format, use the csvlook command:

$ csvlook your_file.csv

Voilà! Your file will magically transform into an easy-to-read table. The columns will be properly spaced, and you'll have horizontal and vertical scrolling at your disposal. 📊👀

You Want More Awesomeness? Try vim with Plugins! 🤘🔌

If you're a vim enthusiast (like us), we have a bonus tip for you. You can use plugins to enhance your vim experience even further!

One such plugin is csv.vim, which provides handy commands for viewing, sorting, searching, and manipulating CSV files within vim. To install it, follow these steps:

  1. Install the vim-plug plugin manager by following the instructions at: https://github.com/junegunn/vim-plug

  2. Edit your vim configuration file (usually located at ~/.vimrc) and add the following line:

Plug 'chrisbra/csv.vim'
  1. Save the file and run the following command within vim to install the plugin:

:PlugInstall

Now you can open your CSV file in vim, and with a simple command, such as :CSVPreview, behold the beautiful table view! 🎇

Your Turn to Shine! ✨

Now that you have the tools to view tabular files like CSVs from the command line, it's time to put them to good use. Try viewing some of your own CSV files, and let us know what you think! Did csvkit exceed your expectations? Did vim plugins bring a whole new dimension to your editing experience? Share your thoughts, experiences, and even some funky CSV files you've encountered. We can't wait to hear from you! 🙌💬

Remember, the journey doesn't end here. Keep exploring, keep learning, and keep sharing your tech adventures with us. Until next time, happy coding! 👩‍💻👨‍💻

Additional Resources 📚🔍

Take Your Tech Career to the Next Level

Our application tracking tool helps you manage your job search effectively. Stay organized, track your progress, and land your dream tech job faster.

Your Product
Product promotion

Share this article

More Articles You Might Like

Latest Articles

Cover Image for How can I echo a newline in a batch file?
batch-filenewlinewindows

How can I echo a newline in a batch file?

Published on March 20, 2060

🔥 💻 🆒 Title: "Getting a Fresh Start: How to Echo a Newline in a Batch File" Introduction: Hey there, tech enthusiasts! Have you ever found yourself in a sticky situation with your batch file output? We've got your back! In this exciting blog post, we

Cover Image for How do I run Redis on Windows?
rediswindows

How do I run Redis on Windows?

Published on March 19, 2060

# Running Redis on Windows: Easy Solutions for Redis Enthusiasts! 🚀 Redis is a powerful and popular in-memory data structure store that offers blazing-fast performance and versatility. However, if you're a Windows user, you might have stumbled upon the c

Cover Image for Best way to strip punctuation from a string
punctuationpythonstring

Best way to strip punctuation from a string

Published on November 1, 2057

# The Art of Stripping Punctuation: Simplifying Your Strings 💥✂️ Are you tired of dealing with pesky punctuation marks that cause chaos in your strings? Have no fear, for we have a solution that will strip those buggers away and leave your texts clean an

Cover Image for Purge or recreate a Ruby on Rails database
rakeruby-on-railsruby-on-rails-3

Purge or recreate a Ruby on Rails database

Published on November 27, 2032

# Purge or Recreate a Ruby on Rails Database: A Simple Guide 🚀 So, you have a Ruby on Rails database that's full of data, and you're now considering deleting everything and starting from scratch. Should you purge the database or recreate it? 🤔 Well, my