tacahiroy / csvv

A simple CSV extractor that allows you to get columns you want

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

csvv

A simple CSV extractor.

Motivation

Sometimes, I need to process too large CSV files from command-line. Needless to say, we have great tools such as cat, sed, grep and awk.

cat /path/to/csv-file | awk -F ',' '{ print $2 "," $1 }'

However, how I can specify columns by column name, instead of column number like $1 or $2? Although I didn't google it, I didn't have clear answer(s) to achieve. So I created csvv.

Installation

go get github.com/tacahiroy/csvv

Build

go build csvv.go

Run

csvv /path/to/csv column1,column2[,column3...]

Example

Here's a CSV file, say users.csv.

id,name,email,github,twitter
1,Bob,bob@aaa.xyz,bobaaa,bob123
2,Jake,jake@aaa.xyz,jakeaaa,jake123

If you want to get fields named id and email, you may run like this:

csvv users.csv id,email

Then you get:

id,email
1,bob@aaa.xyz
2,jake@aaa.xyz

About

A simple CSV extractor that allows you to get columns you want

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%