skip to navigation
skip to content

Not Logged In

pluckr 0.0.3

Pluck columns from CSV files in the command line. Like cut or awk, but doesn't choke on delimiter escaping.

Latest Version: 0.0.9

Pluck columns from csv files in the commandline. Like cut or awk, but without choke on delimiter escaping.

install

pip install pluckr. Done.

usage

Grab columns 2 and 3 from stdin:

pluckr -f 2,3 < sample1.csv

Or straight from a file:

pluckr -f 2,3 sample1.csv

You can also use Python’s negative indices… grab the first and last cols:

pluckr -f 1,-1 sample1.csv

Fields that don’t exist (e.g. -f11111) will be ignored.

Skip header row(s):

cat sample1.csv | pluckr -s1

Read (and write) various delimiters:

pluckr -d, –out-delimiter=| < with-commas.csv > with-pipes.csv

Note that passing tabs as arguments can be awkward; in a pinch, use:

pluckr -d $’t’

help

Via –help:

usage: pluckr [-h] [-f FIELDS] [-i INVERSE] [-d DELIMITER] [-q QUOTECHAR]
[-s SKIP] [infile]

Grab columns from csv input. http://github.com/philadams/pluckr

positional arguments:
infile input file (.csv)
optional arguments:
<kbd>-h, --help</kbd> show this help message and exit
<kbd>-f <var>FIELDS</var>, --fields <var>FIELDS</var></kbd>
 the columns to grab (first column is 1)
<kbd>-i <var>INVERSE</var>, --inverse <var>INVERSE</var></kbd>
 invert the column selection: drop them instead
<kbd>-d <var>DELIMITER</var>, --delimiter <var>DELIMITER</var></kbd>
 field delimiter when reading infile
<kbd>-q <var>QUOTECHAR</var>, --quotechar <var>QUOTECHAR</var></kbd>
 field quotechar when reading infile
<kbd>-s <var>SKIP</var>, --skip <var>SKIP</var></kbd>
 number of rows to skip

future

  • tests!!!
  • not choke when -f not passed…
  • implement -i
  • implement –out-**
  • allow -f to take columns by name?
  • add out delimiter support
  • add out quotechar support
 
File Type Py Version Uploaded on Size
pluckr-0.0.3.tar.gz (md5) Source 2013-04-28 2KB
  • Downloads (All Versions):
  • 20 downloads in the last day
  • 151 downloads in the last week
  • 718 downloads in the last month