Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chand1012/sq
Convert and query JSON, JSONL, CSV, and SQLite with ease!
https://github.com/chand1012/sq
cli csv golang json jsonl scripting sqlite sqlite3
Last synced: about 1 month ago
JSON representation
Convert and query JSON, JSONL, CSV, and SQLite with ease!
- Host: GitHub
- URL: https://github.com/chand1012/sq
- Owner: chand1012
- License: mit
- Created: 2024-02-24T05:25:17.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-27T16:25:22.000Z (10 months ago)
- Last Synced: 2024-06-21T14:29:48.304Z (7 months ago)
- Topics: cli, csv, golang, json, jsonl, scripting, sqlite, sqlite3
- Language: Go
- Homepage:
- Size: 87.9 KB
- Stars: 22
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
sq
Convert and query JSON, JSONL, CSV, and SQLite with ease!
`sq` is a simple yet powerful command line tool for query and converting from and to SQLite, CSV, JSON, and JSONL files, heavily inspired by [ `jq` ](https://jqlang.github.io/jq/).
## Features
* Convert between SQLite, CSV, JSON, and JSONL files.
* Query CSV, JSON, and JSONL using real SQLite queries.
* Allows for rapid scripting and conversion of data.
* Pipe in data or read from files.## Installation
Download a prebuilt binary from the [releases page](https://github.com/chand1012/sq/releases) and add it to your PATH, or use `go install` to install the latest version.
```bash
go install github.com/chand1012/sq@latest
```## Examples
Query some orders from a CSV file. Column names for CSV files are converted to lower case and spaces are replaced with underscores.
```bash
$ sq -r orders.csv 'SELECT country FROM sq WHERE seller_amount > 20 NOT NULL;'
United States of America
United States of America
United States of America
United States of America
United States of America
United States of America
United Kingdom
Canada
United States of America
United States of America
United States of America
United States of America
United States of America
Canada
United States of America
Canada
Canada
Australia
United States of America
...
```Download and query some JSONL datasets.
```bash
$ curl https://raw.githubusercontent.com/TimeSurgeLabs/llm-finetuning/4e934ce602f34f62f4d803c40cd1e7825d216192/data/fingpt-sentiment-1k.jsonl | sq 'SELECT * FROM sq WHERE output = "positive";' -f jsonl > positive.jsonl
```You can even use it with `jq` !
```bash
$ curl https://api.gogopool.com/stakers | jq '.stakers' | sq -t stakers 'SELECT stakerAddr,avaxValidating FROM stakers WHERE avaxValidating > 0;' -f json > stakers.json
```