https://github.com/inkel/csvq
Simple tool for querying CSV files
https://github.com/inkel/csvq
csv go golang
Last synced: 11 months ago
JSON representation
Simple tool for querying CSV files
- Host: GitHub
- URL: https://github.com/inkel/csvq
- Owner: inkel
- License: mit
- Created: 2017-09-13T18:21:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-14T01:31:29.000Z (over 8 years ago)
- Last Synced: 2025-02-17T09:27:08.194Z (about 1 year ago)
- Topics: csv, go, golang
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `csvq` - Simple tool for querying CSV files
I love [`jq`](https://stedolan.github.io/jq/) and I wanted to do something similar for CSV data. So here it is.
**I AM GOING TO REWRITE MUCH OF THIS SO DON'T RELY ON IT FOR NOW**
## Installation
Install the latest version:
```
go install -u github.com/inkel/csvq
```
## Usage
```
Usage of csvq:
-H First line are headers (default true)
-h string
Column to filter
-v string
Value
```
Using the example data in [`encoding/csv`](https://golang.org/pkg/encoding/csv/) package documentation:
```
first_name,last_name,username
"Rob","Pike",rob
Ken,Thompson,ken
"Robert","Griesemer","gri"
```
### Do nothing
```
$ csvq file.csv
first_name,last_name,username
Rob,Pike,rob
Ken,Thompson,ken
Robert,Griesemer,gri
```
### Filter by named column
```
$ csvq -h username -v ken file.csv
first_name,last_name,username
Ken,Thompson,ken
```
Of course, if you pass `-H=false`, meaning the CSV file doesn't have headers, then this will fail with something like:
```
$ csvq -H=false -h first_name -v Rob gophers.csv
strconv.Atoi: parsing "first_name": invalid syntax
```
### Filter by column number
```
$ csvq -h 3 -v johndoe file.csv
first_name,last_name,username
Ken,Thompson,ken
```
This one works whether you enable headers or not.
### Select columns to output
TODO
### Change columns order
TODO
### Change output delimiter
TODO
### Change to JSON
TODO
## License
See [LICENSE](LICENSE).