Module csvutils
[hide private]
[frames] | no frames]

Module csvutils

source code

Transformation utilities for csv (or csv-like) generated rows.

The standard csv module is very useful for parsing tabular data in CSV format. Typically though, one or more transformations need to be applied to the generated rows before being ready to be used; for instance "convert the 3rd column to int, the 5th to float and ignore all the rest". This module provides an easy way to specify such transformations upfront instead of coding them every time by hand.

Two classes are currently available, SequenceTransformer and MappingTransformer, that represent each row as a list (like csv.reader) or dict (like csv.DictReader), respectively.


Requires: Python 2.3 or later.

Author: George Sakkis <george.sakkis AT gmail DOT com>

Classes [hide private]
  RowTransformer
Abstract base transformer class.
  SequenceTransformer
A RowTransformer that expects and returns rows as sequences.
  MappingTransformer
A RowTransformer that expects and returns rows as mappings.