Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thedevsaddam/q
[WIP] "q" a command-line tool to query JSON/XML/YAML/CSV document
https://github.com/thedevsaddam/q
Last synced: 18 days ago
JSON representation
[WIP] "q" a command-line tool to query JSON/XML/YAML/CSV document
- Host: GitHub
- URL: https://github.com/thedevsaddam/q
- Owner: thedevsaddam
- Created: 2019-03-27T11:33:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-24T18:15:44.000Z (over 1 year ago)
- Last Synced: 2024-06-21T18:11:25.913Z (5 months ago)
- Language: Go
- Homepage:
- Size: 2.27 MB
- Stars: 8
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
q
----------
A command-line tool to query JSON/XML/YAML/CSV document### Installation
**For Mac**
```sh
brew tap thedevsaddam/cli https://github.com/thedevsaddam/homebrew-cli.git
brew install thedevsaddam/homebrew-cli/q
```### Examples
**Find**
```sh
cat data.json | q -pretty -find="items.[0].name"
````**Get**
```sh
cat data.json | q -from="items" -pretty
``````sh
cat data.json | q -from="items.[0].name"
```**Command**
```sh
cat data.json | q -from="prices" -command="first" #first,last,count,avg etc
```**Aggregate functions**
```sh
cat data.json | q -from="prices" -command="avg" #sum,min,max,avg,count
``````sh
cat data.json | q --from="items" -command="min:price"
```**Offset**
```sh
cat data.json | q -pretty -from="items" -offset="2"
```**Limit**
```sh
cat data.json | q -pretty -from="items" -limit="4"
```**Distinct**
```sh
cat data.json | q -from="items" -pretty -distinct="price"
```**Pluck**
```sh
cat data.json | q -pretty -from="items" -command="pluck:name"
```**Select/Columns**
```sh
cat data.json | q -from="items" -pretty -columns="name,price"
```**Where**
```sh
cat data.json | q --from="items" --where="name=Fujitsu"
```**OrWhere**
```sh
cat data.json | q --from="items" --where="name=Fujitsu" --orWhere="id=int:1"
```**GroupBy**
```sh
cat data.json | q -pretty -from="items" -groupBy="price"
```**Sort [array]**
```sh
cat data.json | q -pretty -from="prices" -sort="desc"
```**SortBy [array of objects]**
```sh
cat data.json | q -pretty -from="items" -sortBy="price:desc"
```**Type [JSON, XML, YAML, CSV]**
```sh
cat data.csv| q -type="csv" -pretty -where="ISBN=9781846053443" -columns="ASP,ISBN,RRP" # type can be "csv", "xml", "yaml", "json"; default is "json"
```