| Libgretl Reference Manual |
|---|
dbreaddbread — |
#define DB_DESCRIP_LEN enum db_error_codes; enum CompactMethod; typedef dbnumber; db_table; SERIESINFO; int get_native_db_data (const char *dbbase, SERIESINFO *sinfo, double **Z); int get_remote_db_data (const char *dbbase, SERIESINFO *sinfo, double **Z); int get_pcgive_db_data (const char *dbbase, SERIESINFO *sinfo, double **Z); int get_rats_db_data (const char *fname, SERIESINFO *sinfo, double **Z); db_table* read_rats_db (FILE *fp); db_table* read_pcgive_db (FILE *fp); double* compact_db_series (const double *src, SERIESINFO *sinfo, int target_pd, CompactMethod method); double* expand_db_series (const double *src, SERIESINFO *sinfo, int target_pd); void init_datainfo_from_sinfo (DATAINFO *pdinfo, SERIESINFO *sinfo); int set_db_name (const char *fname, int filetype, const PATHS *ppaths, PRN *prn); int db_set_sample (const char *line, DATAINFO *pdinfo); int db_get_series (const char *line, double ***pZ, DATAINFO *datainfo, PRN *prn); void get_db_padding (SERIESINFO *sinfo, DATAINFO *pdinfo, int *pad1, int *pad2); int check_db_import (SERIESINFO *sinfo, DATAINFO *pdinfo); int compact_data_set (double ***pZ, DATAINFO *pdinfo, int newpd, CompactMethod default_method, int monstart, int repday); int expand_data_set (double ***pZ, DATAINFO *pdinfo, int newpd);
typedef enum {
DB_MISSING_DATA = E_MAX + 1,
DB_NO_SUCH_SERIES,
DB_PARSE_ERROR
} db_error_codes;
typedef enum {
COMPACT_NONE,
COMPACT_SUM,
COMPACT_AVG,
COMPACT_SOP,
COMPACT_EOP,
COMPACT_WDAY,
COMPACT_MAX
} CompactMethod;
typedef struct {
char varname[VNAMELEN];
char descrip[MAXLABEL];
int nobs;
char stobs[OBSLEN];
char endobs[OBSLEN];
int pd;
int offset;
int err;
int undated;
} SERIESINFO;
int get_native_db_data (const char *dbbase,
SERIESINFO *sinfo,
double **Z);
dbbase : |
|
sinfo : |
|
Z : |
|
| Returns : |
int get_remote_db_data (const char *dbbase,
SERIESINFO *sinfo,
double **Z);
dbbase : |
|
sinfo : |
|
Z : |
|
| Returns : |
int get_pcgive_db_data (const char *dbbase,
SERIESINFO *sinfo,
double **Z);
dbbase : |
|
sinfo : |
|
Z : |
|
| Returns : |
int get_rats_db_data (const char *fname,
SERIESINFO *sinfo,
double **Z);
Read the actual data values for a series from a RATS database.
fname : |
name of RATS 4.0 database to read from |
sinfo : |
holds info on the given series (input) |
Z : |
data matrix |
| Returns : | 0 on successful completion, E_FOPEN if the data could not be read, and DB_MISSING_DATA if the data were found but there were some missing values. |
db_table* read_rats_db (FILE *fp);
Read the series info from a RATS 4.0 database: read the base block at offset 0 in the data file, and recurse through the directory entries
fp : |
pre-opened stream (caller to close it) |
| Returns : | pointer to a db_table containing the series info, or NULL in case of failure. |
db_table* read_pcgive_db (FILE *fp);
Read the series info from a PcGive database, .in7 file
fp : |
pre-opened stream (caller to close it) |
| Returns : | pointer to a db_table containing the series info, or NULL in case of failure. |
double* compact_db_series (const double *src,
SERIESINFO *sinfo,
int target_pd,
CompactMethod method);
src : |
|
sinfo : |
|
target_pd : |
|
method : |
|
| Returns : |
double* expand_db_series (const double *src,
SERIESINFO *sinfo,
int target_pd);
src : |
|
sinfo : |
|
target_pd : |
|
| Returns : |
void init_datainfo_from_sinfo (DATAINFO *pdinfo, SERIESINFO *sinfo);
pdinfo : |
|
sinfo : |
int set_db_name (const char *fname,
int filetype,
const PATHS *ppaths,
PRN *prn);
fname : |
|
filetype : |
|
ppaths : |
|
prn : |
|
| Returns : |
int db_get_series (const char *line,
double ***pZ,
DATAINFO *datainfo,
PRN *prn);
line : |
|
pZ : |
|
datainfo : |
|
prn : |
|
| Returns : |
void get_db_padding (SERIESINFO *sinfo, DATAINFO *pdinfo, int *pad1, int *pad2);
sinfo : |
|
pdinfo : |
|
pad1 : |
|
pad2 : |
int check_db_import (SERIESINFO *sinfo, DATAINFO *pdinfo);
sinfo : |
|
pdinfo : |
|
| Returns : |
int compact_data_set (double ***pZ,
DATAINFO *pdinfo,
int newpd,
CompactMethod default_method,
int monstart,
int repday);
Compact the data set from higher to lower frequency.
pZ : |
pointer to data array. |
pdinfo : |
data information struct. |
newpd : |
target data frequency. |
default_method : |
code for the default compaction method. |
monstart : |
FIXME add explanation. |
repday : |
"representative day" for conversion from daily
to weekly data (with method COMPACT_WDAY only).
|
| Returns : | 0 on success, non-zero error code on failure. |
int expand_data_set (double ***pZ,
DATAINFO *pdinfo,
int newpd);
Expand the data set from lower to higher frequency: an "expert" option. This is supported at present only for expansion from annual to quarterly or monthly, or from quarterly to monthly.
pZ : |
pointer to data array. |
pdinfo : |
data information struct. |
newpd : |
target data frequency |
| Returns : | 0 on success, non-zero error code on failure. |
| << gretl_xml | dbwrite >> |