Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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"
```