A handy, simple (and hackish!) CLI for modifying, filtering and exporting CSV structures.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE.txt
README.md
index.js
package.json

README.md

csv-cli

csv-cli is a handy, simple (and hackish!) command line utility for modifying, filtering and exporting CSV structures.

Examples

Assume you have a CSV structure representing payments, such as:

Name,Item Name,Amount
Joe,MacBook Pro,2500.00
Bob,MacBook Air,1500.00
Lou,iPhone 7,200.00
Liz,Apple Watch,200.00

Using where you can provide filter conditions. These can be complex Javascript statements (since they are directly eval'd) that return boolean.

  • Filter large payments: csv --in my_payments.csv --where "entry.Amount >= 1000"
  • Or large payments by Joe: csv --in my_payments.csv --where "entry.Amount >= 1000 && entry.Name == 'Joe'"

Using select you can filter specific columns that you want exported.

  • Filter large payments by Joe and only export what he's purchased: csv --in my_payments.csv --where "entry.Amount >= 1000 && entry.Name == 'Joe'" --select Name

You can use stats to get stats about a numerical column.

Sample Output for the Amount column:

{
    count: 1,
    average: 2500,
    sum: 2500,
    high: 2500,
    low: 200,
    range: 2300
}

Install

  1. Clone the repo with git clone https://github.com/Cryptkeeper/csv-cli
  2. Run npm install -g
  3. You're done!