Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/herrfugbaum/qsv
Process CSV and TSV files with SQL.
https://github.com/herrfugbaum/qsv
cli command-line-tool csv dsv javascript js node nodejs tsv
Last synced: about 3 hours ago
JSON representation
Process CSV and TSV files with SQL.
- Host: GitHub
- URL: https://github.com/herrfugbaum/qsv
- Owner: herrfugbaum
- License: mit
- Created: 2018-11-14T16:38:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-27T19:10:56.000Z (over 2 years ago)
- Last Synced: 2025-02-02T12:06:45.287Z (4 days ago)
- Topics: cli, command-line-tool, csv, dsv, javascript, js, node, nodejs, tsv
- Language: JavaScript
- Homepage:
- Size: 845 KB
- Stars: 13
- Watchers: 2
- Forks: 5
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Contributing: .github/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
Process .csv files with a SQL like syntax.
[![Build Status](https://travis-ci.org/herrfugbaum/qsv.svg?branch=master)](https://travis-ci.org/herrfugbaum/qsv)
[![codecov](https://codecov.io/gh/herrfugbaum/qsv/branch/master/graph/badge.svg)](https://codecov.io/gh/herrfugbaum/qsv)
[![Maintainability](https://api.codeclimate.com/v1/badges/07a7c20e81c6ab493132/maintainability)](https://codeclimate.com/github/herrfugbaum/qsv/maintainability)
[![Mutation Score](https://badge.stryker-mutator.io/github.com/herrfugbaum/qsv/master)](https://badge.stryker-mutator.io/github.com/herrfugbaum/qsv/master)[![Gitter](https://img.shields.io/gitter/room/herrfugbaum/qsv.svg)](https://gitter.im/qsv-chat/Lobby) [![Greenkeeper badge](https://badges.greenkeeper.io/herrfugbaum/qsv.svg)](https://greenkeeper.io/)
*Work in Progress*
*Currently supports:*
* SELECT
* WHERE
* ORDER BY (single column)
* LIMIT![qsv demo session](https://slamcode.com/qsv/demo.gif)
```bash
npm install qsv -g
```Or if you're using yarn
```bash
yarn global add qsv
```
For files with headers:
```bash
qsv -p "./path/to/my/file.csv" -h
```For files without headers:
```bash
qsv -p "./path/to/my/file.csv"
```
After loading the file you will get into REPL mode, indicated by the QSV> prompt.
In REPL mode you can use SQL Queries against your .csv file.## Examples:
### SELECT
```sql
SELECT * FROM table
``````sql
SELECT column1, column2 FROM table
```### WHERE
Supported operators
| operator | meaning |
|----------|-----------------------|
| = | Equal |
| <> | Not Equal |
| > | Greater Than |
| < | Less Than |
| >= | Greater Than or Equal |
| <= | Less Than or Equal |Examples
```sql
SELECT * FROM table WHERE column1 > 10SELECT * FROM table WHERE column1 < 10
SELECT * FROM table WHERE column1 >= 10
SELECT * FROM table WHERE column1 <= 10
SELECT * FROM table WHERE column1 <> Peter
SELECT * FROM table WHERE colum2 = Mexico
```### ORDER BY
```sql
-- ASC is default for ORDER BY so this
SELECT * FROM table ORDER BY column1
-- is the same as:
SELECT * FROM table ORDER BY column1 ASC
-- For descending order you need to add DESC
SELECT * FROM table ORDER BY column1 DESC
```table is just a placeholder, you don't need to specify something that makes sense, just don't leave it blank.
column1 and column2 are examples for the header fields.If your .csv file doesn't have headers omit the -h option.
Your table will receive enumerated headers in memory, so you can query it like this:```sql
SELECT 0, 1 FROM table
```Options
| Option | Verbose Version | Description |
| ------ | --------------- | ------------------------------------------- |
| -h | | Indicate that the file to parse has headers |
| -d | | Specifiy the delimiter of your file. |