Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install csvfilter

How to install csvfilter

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install csvfilter
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.2.2 Available View build log
0.1.1 Available View build log
Windows (64-bit)
0.2.2 Available View build log
0.1.1 Available View build log
Mac OS X (10.5+)
0.2.2 Available View build log
0.1.1 Available View build log
Linux (32-bit)
0.2.2 Available View build log
0.1.1 Available View build log
Linux (64-bit)
0.2.2 Available View build log
0.1.1 Available View build log
 
Imports
Lastest release
version 0.2.2 on May 23rd, 2012

A simple wrapper around Python's CSV module to provide a command-line tool for filtering columns from a CSV file. This is useful as standard tools like awk don't account for the quoting and escaping used in CSV files. It's a bit like cut but for CSVs.

Install

From PyPi:

pip install csvfilter

Use

Pluck fields 1, 3 and 5 from in.csv:

csvfilter -f 1,3,5 in.csv > out.csv

Pluck all fields apart from column 2 from STDIN:

cat in.csv | csvfilter -f 2 -i > out.csv

Convert pipe-separated file to comma-separated (default-separated output is comma-separated):

csvfilter -d"|" in.psv > out.csv

Skip the header row:

cat in.csv | csvfilter --skip=1

As you can see, CSV data can be supplied through STDIN or by running csvfilter directly on a file.

Help is in the usual place:

$ csvfilter --help

Usage: csvfilter [options] [inputfile]

Source: https://github.com/codeinthehole/csvfilter/

Options:
-h, --help            show this help message and exit
-f FIELDS, --fields=FIELDS
                        Specify which fields to pluck
-s SKIP, --skip=SKIP  Number of rows to skip
-d DELIMITER, --delimiter=DELIMITER
                        Delimiter of incoming CSV data
-i, --inverse         Invert the filter - ie drop the selected fields
--out-delimiter=OUT_DELIMITER
                        Delimiter to use for output
--out-quotechar=OUT_QUOTECHAR
                        Quote character to use for output

Contribute

After cloning, install the testing requirements:

pip install -r requirements.txt

Install the package in 'develop' mode to bring the executable onto your path:

./setup.py develop

Run the tests with:

nosetests

and use the fixture files:

cat fixtures/au.csv | csvfilter -f 3,1,2 -s 1
csvfilter fixutres/au.csv -f 1,2 -i

Subscribe to package updates

Last updated May 23rd, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.