Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A shell-like object pipeline

Project description

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%.


pip install piper


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.


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
    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 = [

for cost in flow(rows, pipeline):

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for piper, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size piper-0.1.0.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page