next up previous index
Next: flt_storage Up: Data Storage Previous: mysql_storage   Index

csv_storage and tab_storage

Both csv_storage and tab_storage provide a file-based storage for datasets. They are based upon Python's csv module, and thus will appropriately quote any data as necessary.

The constructor of this class expects an entry storage_location in its arguments. It should be a base directory on a hard drive where the data will be stored to and loaded from.

The methods load_table() and determine_field_names() interpret the parameter table_name as a file name without extension (relative to the base directory) in which the data are stored in an ASCII format. The extension is added automatically. The data are stored with one attribute per column. The first row contains the attribute names and optional type information for each column. The type information, if provided, is appended to the column name and separated by a colon, as in id:int32 which specifies to use the numpy int32 type for storing the id values. The type may be any of the numpy types in Table 7.1:


Table 7.1: Allowable column types for csv_storage and tab_storage.
Storage Type
bool8
int8
uint8
int16
uint16
int32
uint32
int64
uint64
float32
float64
complex64
complex128


If type information is not included, Opus will use float64 for numeric data and string for string data.

For instance, the csv_storage for a dataset with three attributes a, b, and c containing two rows of data could look like:

a:int8,b:float32,c:string40
1,3.14,hello
2,2.18,there

The method write_dataset() writes the data to the file whose name is constructed by appending a to the out_table_name entry in the write_resources argument to write_dataset(). csv_storage uses the ``csv'' suffix. tab_storage uses the ``tab'' suffix. write_dataset() always appends type information to the column names.


next up previous index
Next: flt_storage Up: Data Storage Previous: mysql_storage   Index
info (at) urbansim.org