next up previous index
Next: sql_storage Up: Data Storage Previous: dict_storage   Index

csv_storage and tab_storage

Both csv_storage and tab_storage provide file-based storage. They are based upon Python's csv module, and thus will appropriately format 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.

For these storage classes, all implemented methods of the storage interface which accept a table_name parameter interpret it as a file name without extension (relative to the base directory) in which the data is stored (or where it should be stored). The extension is added automatically. The data is 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 24.1.


Table 24.1: Allowable column types for csv_storage and tab_storage. x in the last line is an integer determining length of the string.
Column Type
bool8
int8
uint8
int16
uint16
int32
uint32
int64
uint64
float32
float64
complex64
complex128
stringx


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


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