QueryCSV: Execute SQL Queries Directly on Your CSV Files

If you are constrained to working solely with data stored in CSV files, here is a utility that can save you a lot of time.

QueryCSV is a command-line application that enables you to query CSV files using syntax similar to SQL. Available for various operating systems, this app allows you to extract specific data from any CSV file simply by using queries.

Let’s consider, for example, a scenario where you have a CSV file containing sales data and want to know how many units of a specific product have been sold in a certain region. With QueryCSV, you can simply run a command-line query to quickly obtain the information you need.

For those interested in CSV files and their manipulation, it’s worth noting that the author of QueryCSV has created different versions for various operating systems, including even older ones. Additionally, each target system has added conversions between Unicode and various character encodings.

To use QueryCSV on your own machine, visit the project’s GitHub repository and download the version compatible with your operating system. Once downloaded, you can start running queries on your CSV files.

Here is an example of a CSV containing a list of employees and their ages:

Name, 
Department Rafferty, 
31 Jones, 
33 Heisenberg, 
33 Robinson, 
34 Smith, 
34 Williams, ""

And a departments.csv File with the following content:

DepartmentID, 
DepartmentName 31, 
Sales 33, 
Engineering 34, 
Office Staff 35, 
Marketing

You can create a file called getEngineers.qry To be used for the query, specify the data you want to retrieve with the appropriate join. In this example, we are looking to list the names of employees with their departments:

select a.lastName as surname, b.DepartmentName as department
from 'employees.csv' as a
join 'departments.csv' as b on b.DepartmentID = a.DepartmentID
where a.DepartmentID = 33

Finally, from the command line, run the query on the data files using the following command:

querycsv getEngineers.qry

And there you go; you will then obtain a result similar to this:

last name, department
Jones, Engineering
Heisenberg, Engineering

Pretty cool, right? Don’t hesitate to try QueryCSV by clicking here! Guaranteed time-saving!

"Because of the Google update, I, like many other blogs, lost a lot of traffic."

Join the Newsletter

Please, subscribe to get our latest content by email.

Mohamed SAKHRI
Mohamed SAKHRI

I'm the creator and editor-in-chief of Tech To Geek. Through this little blog, I share with you my passion for technology. I specialize in various operating systems such as Windows, Linux, macOS, and Android, focusing on providing practical and valuable guides.

Articles: 1417

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *