IRIS Toolbox Reference Manual

dbsave

Save database as CSV file

Syntax

List = dbsave(D,FName)
List = dbsave(D,FName,Dates,...)

Output arguments

Input arguments

Options

Description

The data saved include also imaginary parts of complex numbers.

Saving user data with the database

If your database contains field named 'userdata=', this will be saved in the CSV file on a separate row. The 'userdata=' field can be any combination of numeric, char, and cell arrays and 1-by-1 structs.

You can use the 'userdata=' field to describe the database or preserve any sort of metadata. To change the name of the field that is treated as user data, use the 'userData=' option.

Example

Create a simple database with two time series.

d = struct();
d.x = tseries(qq(2010,1):qq(2010,4),@rand);
d.y = tseries(qq(2010,1):qq(2010,4),@rand);

Add your own description of the database, e.g.

d.userdata = {'My database',datestr(now())};

Save the database as CSV using dbsave,

dbsave(d,'mydatabase.csv');

When you later load the database,

d = dbload('mydatabase.csv')

d = 

   userdata: {'My database'  '23-Sep-2011 14:10:17'}
          x: [4x1 tseries]
          y: [4x1 tseries]

the database will preserve the 'userdata=' field.

Example

To change the field name under which you store your own user data, use the 'userdata=' option when running dbsave,

d = struct();
d.x = tseries(qq(2010,1):qq(2010,4),@rand);
d.y = tseries(qq(2010,1):qq(2010,4),@rand);
d.MYUSERDATA = {'My database',datestr(now())};
dbsave(d,'mydatabase.csv',Inf,'userData=','MYUSERDATA');

The name of the user data field is also kept in the CSV file so that dbload works fine in this case, too, and returns a database identical to the saved one,

d = dbload('mydatabase.csv')

d = 

   MYUSERDATA: {'My database'  '23-Sep-2011 14:10:17'}
            x: [4x1 tseries]
            y: [4x1 tseries]