This page contains the Imptools Module documentation.
This program implements a database importer that reads from ascii-input files to the django database. It’s generic and is controlled from a mapping file.
Bases: object
This class implements an object that represents an open file from which one can read blocks. The object keeps track of its own block-step speed and will return lines as defined by this speed. E.g. for a line-step speed of 0.5, it will return the same line twice in a row whereas for a step speed of 2, will return every second block etc.
If endblock is \n (default), the block will infact represent a line.
generator, stepping through blocks
Return a block from the file.
This method understand both slower block stepping (0 < blockstep < 1) and faster (> 1)
formats time to nice format.
Process one line/block of data. Linedata is a tuple that always starts with the raw string for the line. The function with its arguments is read from the column_dict and applied to the linedata. The result is returned, after checking for the NULL value.
Intended to be called from inside a traceback exception with the exception object as first argument. Captures the latest traceback.
Process one file definition from a config dictionary by processing the file name stored in it and parse it according to the mapping.
file_dict - config dictionary representing one input file structure (for an example see e.g. mapping_vald3.py)
Step through a list of mappings describing the relation between (usually ascii-)files and django database fields. This should ideally not have to be changed for different database types.
Read the config dictionary from a file. Note: very unsafe, since the content gets executed. Have a look at createcfg() to see how it should look like.
Check the mapping definition to make sure it contains a structure suitable for the parser.