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 piper

How to install piper

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install piper
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
Linux (64-bit)
0.1.0 Available View build log
0.1.0 Available View build log
 
Author
License
ISC
Imports
Lastest release
version 0.1.0 on Sep 20th, 2013

Piper is a pipeline for python objects. It's great. Go, use it.

Piper enables you to write clean, decoupled functions to process all that dirty data you have. It borrows freely from the UNIX philosophy, processing data much like a shell pipeline. Chain together simple, orthogonal functions, and reduce spaghetti by 95%.

Install

pip install piper

Overview

Each pipe in the pipeline takes an item and a context. It returns an iterable of the outputs, which get passed to the next pipe. It's strictly serial, so at each stage of the pipeline the first object gets fully processed before anything is done with the second.

flow takes an iterable (your data set), and a list of functions ("pipes") to pass it through. The output of each pipe serves as the input to the next. The final result is just another iterable.

Session is a communication facility. You can use it as a simple way to share state between pipes, and to skip the remainder of the pipeline for specific outputs.

pipe turns a simple 1-input 1-output function into one that can fit in the pipeline.

verbose is a pipe decorator that prints all the goings on to stdout.

Example

import csv
from dateutil.parser import parse as parsedate
from piper import flow

def to_dict(row, session):
    if 'headings' not in session:
        session['headings'] = row
        return
    val = dict(zip(session['headings'], row))
    val['date'] = parsedate(val['date'])
    val['cost'] = float(val['price']) * float(val['quantity'])
    yield val

def skip_mondays(row, session):
    if row['date'].weekday() != 0:
        yield row

def get_cost(row, session):
    yield row['cost']

rows = csv.reader(some_csv_content)
pipeline = [
    to_dict,
    skip_mondays,
    get_cost,
]

for cost in flow(rows, pipeline):
    print(cost)

Subscribe to package updates

Last updated Sep 20th, 2013

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.