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!