

    \filetitle{dbload}{Create database by loading CSV file}{dbase/dbload}

	\paragraph{Syntax}
 
 \begin{verbatim}
 D = dbload(FNAME, ...)
 D = dbload(D,FNAME, ...)
 \end{verbatim}
 \paragraph{Input arguments}
 
 \begin{itemize}
 \item
   \texttt{FNAME} {[} char \textbar{} cellstr {]} - Input CSV file name
   or a cell array of CSV file names that will be combined.
 \item
   \texttt{D} {[} struct {]} - An existing database (struct) to which the
   CSV entries will be added.
 \end{itemize}
 \paragraph{Output arguments}
 
 \begin{itemize}
 \item
   \texttt{D} {[} struct {]} - Database created from the input CSV
   file(s).
 \end{itemize}
 \paragraph{Options}
 
 \begin{itemize}
 \item
   \texttt{'case='} {[} \texttt{'lower'} \textbar{} \texttt{'upper'}
   \textbar{} \emph{empty} {]} - Change case of variable names.
 \item
   \texttt{'commentRow='} {[} char \textbar{} cellstr \textbar{}
   \emph{\texttt{\{'comment','comments'\}}} {]} - Label at the start of
   row that will be used to create tseries object comments.
 \item
   \texttt{'dateFormat='} {[} char \textbar{} \emph{\texttt{'YYYYFP'}}
   {]} - Format of dates in first column.
 \item
   \texttt{'delimiter='} {[} char \textbar{} \emph{\texttt{','}} {]} -
   Delimiter separating the individual values (cells) in the CSV file; if
   different from a comma, all occurences of the delimiter will replaced
   with commas --- note that this will also affect text in comments.
 \item
   \texttt{'freq='} {[} \texttt{0} \textbar{} \texttt{1} \textbar{}
   \texttt{2} \textbar{} \texttt{4} \textbar{} \texttt{6} \textbar{}
   \texttt{12} \textbar{} \texttt{365} \textbar{} \texttt{'daily'}
   \textbar{} \emph{empty} {]} - Advise frequency of dates; if empty,
   frequency will be automatically recognised.
 \item
   \texttt{'freqLetters='} {[} char \textbar{} \emph{\texttt{'YHQBM'}}
   {]} - Letters representing frequency of dates in date column.
 \item
   \texttt{'leadingRow='} {[} char \textbar{} numeric \textbar{}
   \emph{empty} {]} - String at the beginning (i.e.~in the first cell) of
   the row with variable names; or the line number at which the row with
   variable names begins.
 \item
   \texttt{'nameFunc='} {[} function\_handle \textbar{} \emph{empty} {]}
   - Function used to change or transform the variable names; if empty,
   the variable names from the CSV are used as they are.
 \item
   \texttt{'nan='} {[} char \textbar{} \emph{\texttt{NaN}} {]} - String
   representing missing observations (case insensitive).
 \item
   \texttt{'skipRows='} {[} char \textbar{} cellstr \textbar{} numeric
   \textbar{} \emph{empty} {]} - Skip rows whose first cell matches the
   string or strings (regular expressions); alternatively, you can
   specify a vector of row numbers to be skipped.
 \item
   \texttt{'userdata='} {[} char \textbar{} \emph{\texttt{Inf}} {]} -
   Field name under which the database userdata loaded from the CSV file
   (if they exist) will be stored in the output database; if
   \texttt{'userData'=Inf} the field name will be read from the CSV file
   (and will be thus identical to the originally saved database).
 \item
   \texttt{'userdataField='} {[} char \textbar{} \emph{\texttt{'.'}} {]}
   - A leading character denoting userdata fields for individual time
   series. If empty, no userdata fields will be read.
 \end{itemize}
 \paragraph{Description}
 
 Use the \texttt{'freq='} option whenever there is ambiguity in
 intepreting the date strings, and IRIS is not able to determine the
 frequency correctly (see Example 1).
 
 \subparagraph{Structure of CSV database files}
 
 The minimalist structure of a CSV database file has a leading row with
 variables names, a leading column with dates in the basic IRIS format,
 and individual columns with numeric data:
 
 \begin{verbatim}
 +---------+---------+---------+--
 |         |       Y |       P |
 +---------+---------+---------+--
 |  2010Q1 |       1 |      10 |
 +---------+---------+---------+--
 |  2010Q2 |       2 |      20 |
 +---------+---------+---------+--
 |         |         |         |
 \end{verbatim}
 You can add a comment row (must be placed before the data part, and
 start with a label `Comment' in the first cell) that will also be read
 in and assigned as comments to the individual tseries objects created in
 the output database.
 
 \begin{verbatim}
 +---------+---------+---------+--
 |         |       Y |       P |
 +---------+---------+---------+--
 | Comment |  Output |  Prices |
 +---------+---------+---------+--
 |  2010Q1 |       1 |      10 |
 +---------+---------+---------+--
 |  2010Q2 |       2 |      20 |
 +---------+---------+---------+--
 |         |         |         |
 \end{verbatim}
 You can use a different label in the first cell to denote a comment row;
 in that case you need to set the option \texttt{'commentRow='}
 accordingly.
 
 All CSV rows whose names start with a character specified in the option
 \texttt{'userdataField='} (a dot by default) will be added to output
 tseries objects as fields of their userdata.
 
 \begin{verbatim}
 +---------+---------+---------+--
 |         |       Y |       P |
 +---------+---------+---------+--
 | Comment |  Output |  Prices |
 +---------+---------+---------+--
 | .Source |   Stat  |  IMFIFS |
 +---------+---------+---------+--
 | .Update | 17Feb11 | 01Feb11 |
 +---------+---------+---------+--
 | .Units  | Bil USD |  2010=1 |
 +---------+---------+---------+--
 |  2010Q1 |       1 |      10 |
 +---------+---------+---------+--
 |  2010Q2 |       2 |      20 |
 +---------+---------+---------+--
 |         |         |         |
 \end{verbatim}
 \paragraph{Example 1}
 
 Typical example of using the \texttt{'freq='} option is a quarterly
 database with dates represented by the corresponding months, such as a
 sequence 2000--01--01, 2000--04--01, 2000--07--01, 2000--10--01, etc. In
 this case, you can use the following options:
 
 \begin{verbatim}
 d = dbload('filename.csv','dateFormat','YYYY-MM-01','freq',4);
 \end{verbatim}


