Project

cutcsv

0.0
No commit activity in last 3 years
No release in over 3 years
A utility that allows you to extract fields from CSV files, outputting a new CSV with just the fields that you want.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 5.2.0
 Project Readme

cutcsv

CSV is a file format with... issues. Lots of issues. One of the most annoying — for me at least — is that it breaks the standard Unix cut command, which is otherwise a tool that I use every day.

If you run cut on a CSV and pass in , as a delimiter, it often just works. But if you've got quoted fields that contain commas, or if you've got fields that continue onto multiple lines, things get screwy fast.

For the few times that you need to extract fields from such a file, cutcsv should have your back.

Installation

cutcsv can be installed via RubyGems:

$ gem install cutcsv

Usage

Like standard cut, cutcsv accepts input either from standard input or from a named list of files. So, you can do:

some-command | cutcsv -f 1,3

...or you can do:

cutcsv -f 1,3 some-file.csv

The -f argument is exactly like standard cut. You can pass in just one field (like -f 4), a comma separated list of fields (like -f 1,3,5), ranges of fields (like -f 1-10), or all of these things (like 1-3,5,7,9-11,20).