Package etl :: Class transformer
[hide private]
[frames] | no frames]

Class transformer

source code

object --+
         |
        transformer


Transfer data into different type.
Pass description like :-
  - INTEGER  : convert string to Integer object.
  - FLOAT    : convert string to float object.
  - LONG     : convert string to long integer object.
  - COMPLEX  : convert string to complex number.
  - STRING   : convert string to string.
  - DATE     : convert string to datetime.date object.
  - DATETIME : convert string to datetime.datetime object.
  - TIME     : convert string to datetime.time object.
  - BOOLEAN  : convert string to boolean object.
Example :-
   datas = [{'id': '1', 'name': 'abc', 'invoice_date': '2009-10-20', 'invoice_amount': '200.00', 'is_paid': '1'}]
   description= {'id': etl.transformer.LONG, 'name': etl.transformer.STRING, 'invoice_date': etl.transformer.DATE, 'invoice_amount': etl.transformer.FLOAT, 'is_paid': etl.transformer.BOOLEAN}
   return = [{'id': 1, 'name': 'abc', 'invoice_date': datetime.date object (2009, 10, 20), 'invoice_amount': 200.00, 'is_paid': True}]



Instance Methods [hide private]
 
__init__(self, description)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
action_error(self, e) source code
 
transform(self, data) source code

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

Class Variables [hide private]
  BOOLEAN = 'bool'
  COMPLEX = 'complex'
  DATE = 'date'
  DATETIME = 'datetime'
  FLOAT = 'float'
  INTEGER = 'int'
  LONG = 'long'
  STRING = 'str'
  TIME = 'time'
  _transform_method = {'bool': <type 'bool'>, 'complex': <type '...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, description)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

Class Variable Details [hide private]

_transform_method

Value:
{'bool': <type 'bool'>,
 'complex': <type 'complex'>,
 'date': <function <lambda> at 0xac1b90>,
 'datetime': <function <lambda> at 0xac1c80>,
 'float': <type 'float'>,
 'int': <type 'int'>,
 'long': <type 'long'>,
 'str': <type 'unicode'>,
...