Package cjklib :: Module build :: Class CSVFileLoader
[hide private]
[frames] | no frames]

Class CSVFileLoader

source code


Builds a table by loading its data from a list of comma separated values (CSV).

Nested Classes [hide private]
  DefaultDialect
Defines a default dialect for the case sniffing fails.
Instance Methods [hide private]
 
__init__(self, dataPath, dbConnectInst, quiet=False)
Constructs the TableBuilder.
source code
instance
getCSVReader(self, fileHandle)
Returns a csv reader object for a given file name.
source code
 
build(self)
Build the table provided by the TableBuilder.
source code
 
remove(self)
Removes the table provided by the TableBuilder from the database.
source code

Inherited from TableBuilder: buildIndexObjects, buildTableObject, findFile

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

Static Methods [hide private]
 
unicode_csv_reader(unicode_csv_data, dialect, **kwargs) source code
 
utf_8_encoder(unicode_csv_data) source code
 
byte_string_dialect(dialect) source code
Class Variables [hide private]
  TABLE_CSV_FILE_MAPPING = ''
csv file path
  TABLE_DECLARATION_FILE_MAPPING = ''
file path containing SQL create table code.
  INDEX_KEYS = []
Index keys (not unique) of the created table

Inherited from TableBuilder: DEPENDS, PROVIDES

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, dataPath, dbConnectInst, quiet=False)
(Constructor)

source code 

Constructs the TableBuilder.

Parameters:
  • dataPath - optional list of paths to the data file(s)
  • dbConnectInst - instance of a DatabaseConnector. If not given all sql code will be printed to stdout.
  • quiet - if true no status information will be printed to stderr
Overrides: object.__init__
(inherited documentation)

getCSVReader(self, fileHandle)

source code 

Returns a csv reader object for a given file name.

The file can start with the character '#' to mark comments. These will be ignored. The first line after the leading comments will be used to guess the csv file's format.

Parameters:
  • fileHandle (file) - file handle of the CSV file
Returns: instance
CSV reader object returning one entry per line

build(self)

source code 

Build the table provided by the TableBuilder.

Methods should raise an IOError if reading a data source fails. The DatabaseBuilder knows how to handle this case and is able to proceed.

Overrides: TableBuilder.build
(inherited documentation)

remove(self)

source code 

Removes the table provided by the TableBuilder from the database.

Overrides: TableBuilder.remove
(inherited documentation)