Module csvutils :: Class RowTransformer
[hide private]
[frames] | no frames]

Class RowTransformer

source code

object --+
         |
        RowTransformer
Known Subclasses:
MappingTransformer, SequenceTransformer

Abstract base transformer class.

Instance Methods [hide private]
 
__init__(self, key_adaptors, **kwds)
Specifies the transformations to apply for each row.
source code
 
__call__(self, rows)
Transform the given rows by this transformer.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, key_adaptors, **kwds)
(Constructor)

source code 
Specifies the transformations to apply for each row.
Parameters:
  • key_adaptors (Sequence of (key,adaptor) pairs) - Specifies the adaptor to transform each column. A column is identified by some key and adaptor is either a callable f(x) or None (equivalent to the identity lambda x:x).
  • default (Callable f(x) or None) - An adaptor for all columns not specified explicitly in key_adaptors.
  • include (Iterable of keys) - The columns to include for each row:
    • If given, only the items at the respective columns are included, in the same order.
    • Otherwise if default is given, all columns are included.
    • Otherwise, if neither include or default are given, only the keys specified in key_adaptors are included.
  • exclude (Iterable of keys) - The columns to exclude for each row. This takes precedence over all other options: a column specified in exclude will never be included in the transformed rows.
Overrides: object.__init__

__call__(self, rows)
(Call operator)

source code 
Transform the given rows by this transformer.
Parameters:
  • rows - An iterable of rows. The representation of a row is up to concrete subclasses to decide.
Returns:
An iterator over the transformed rows.