Install qsv on Ubuntu 24.04

Install qsv on Ubuntu 24.04

The qsv command line tool is designed for handling CSV files. It is a fast and versatile tool that provides a wide range of functionalities for processing CSV data. The qsv allows users to search, slice, split, join, sort, and perform various other operations on CSV data, making it a powerful tool for managing and analyzing CSV files. This tutorial explains how to install qsv on Ubuntu 24.04.

Install qsv

Retrieve the latest version tag of the qsv release from GitHub and store the version tag in a variable:

QSV_VERSION=$(curl -s "https://api.github.com/repos/jqnatividad/qsv/releases/latest" | grep -Po '"tag_name": "\K[0-9.]+')

Download archive file from releases page:

wget -qO qsv.zip https://github.com/jqnatividad/qsv/releases/latest/download/qsv-$QSV_VERSION-x86_64-unknown-linux-gnu.zip

After downloading, extract archive to temporary location:

unzip -q qsv.zip -d qsv-temp

Move the qsv executable from the temporary directory to the /usr/local/bin:

sudo mv qsv-temp/qsv /usr/local/bin

We can check qsv version as follows:

qsv --version

Remove the temporary directory and the downloaded file:

rm -rf qsv-temp qsv.zip

Testing qsv

Create simple CSV file:

echo -e 'name,age\nJohn,25\nJames,29\nOliver,35\nEmma,31' > test.csv

The qsv tool enables various functions. For instance, the table argument can be used to show CSV data in a well-aligned format.

qsv table test.csv

Output:

name    age
John    25
James   29
Oliver  35
Emma    31

The count argument enables counting the number of rows in a CSV file.

qsv count test.csv

Output:

4

We can use regular expressions to search for specific fields within rows. For instance, the command below retrieves all rows in a CSV file where the name field begins with the letter J.

qsv search -s name '^J' test.csv

Output:

name,age
John,25
James,29

Uninstall qsv

To uninstall qsv, remove the associated file:

sudo rm -rf /usr/local/bin/qsv

Leave a Comment

Cancel reply

Your email address will not be published.