csvq

command module
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2017 License: MIT Imports: 7 Imported by: 0

README

csvq

SQL-like query language for csv

Build Status codecov

csvq is a command line tool to operate CSV files. You can read, update, delete CSV records with SQL-like query.

You can also execute multiple operations sequentially in managed transactions by passing a procedure as a command argument or a source file. In the procedure, you can use variables, cursors, temporary tables, and other features.

Install

Install executable binary
  1. Download an archive file from release page.
  2. Extract the downloaded archive and add a binary file in it to your path.
Build from source
Requirements

Go 1.9 (ref. Getting Started - The Go Programming Language)

Build with either of the following two ways
Use go get
  1. $ go get -u github.com/mithrandie/csvq
Build with strict dependencies
  1. Install GNU Make
  2. $ go get -d github.com/mithrandie/csvq
  3. Change directory to $GOPATH/github.com/mithrandie/csvq
  4. $ make deps
  5. $ make install

Usage

# Simple query
csvq "select id, name from `user.csv`"
csvq "select id, name from user"

# Specify data delimiter as tab character
csvq -d "\t" "select count(*) from `user.csv`"

# Load no-header-csv
csvq --no-header "select c1, c2 from user"

# Load from redirection or pipe
csvq "select * from stdin" < user.csv
cat user.csv | csvq "select *"

# Output in JSON format
csvq -f json "select integer(id) as id, name from user"

# Output to a file
csvq -o new_user.csv "select id, name from user"

# Load statements from file
$ cat statements.sql
VAR @id := 0;
SELECT @id := @id + 1 AS id,
       name
  FROM user;

$ csvq -s statements.sql

# Execute statements in the interactive shell
$ csvq
csvq > UPDATE users SET name = 'Mildred' WHERE id = 2;
1 record updated on "/home/mithrandie/docs/csv/users.csv".
csvq > COMMIT;
Commit: file "/home/mithrandie/docs/csv/users.csv" is updated.
csvq > EXIT;

# Show help
csvq -h

More details >> https://mithrandie.github.io/csvq

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
lib
cmd
csv

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL