GdaDataModelImport

## GdaDataModelImport GdaDataModelImport — |

## Synopsis

                GdaDataModelImport;
                GdaDataModelImportClass;
                GdaDataModelImportPrivate;
    GdaDataModel* gda_data_model_import_new_file
                                                (const gchar *filename,
                                                 gboolean random_access,
                                                 GdaParameterList *options);
    GdaDataModel* gda_data_model_import_new_mem (const gchar *data,
                                                 gboolean random_access,
                                                 GdaParameterList *options);
    GdaDataModel* gda_data_model_import_new_xml_node
                                                (xmlNodePtr node);
    GSList*     gda_data_model_import_get_errors
                                                (GdaDataModelImport *model);
    void        gda_data_model_import_clean_errors
                                                (GdaDataModelImport *model);

## Object Hierarchy

      GObject
       +----GdaObject
             +----GdaDataModelImport

## Implemented Interfaces

GdaDataModelImport implements GdaDataModel.

## Properties

      "data"                 gchararray            : Read / Write / Construct Only
      "filename"             gchararray            : Read / Write / Construct Only
      "options"              gpointer              : Read / Write / Construct Only
      "random-access"        gboolean              : Read / Write / Construct Only
      "xml-node"             gpointer              : Read / Write / Construct Only

## Description

Imports data from a string or a file

The GdaDataModelImport data model imports data from a string or a file. The data can either be in a CSV (comma separated values) format or in an XML format as described by the libgda-array.dtd DTD (as a side way it is also possible to import data from an already-build XML tree validated against that DTD).

The caller must decide, upon construction, if the new GdaDataModelImport must support random access or simply a cursor based access. Random acces makes it easier to use the resulting data model but consumes more memory as all the data is copied in memory, and is thus not suitable for large data sets. Note that importing from an already-build XML tree will always result in a random access data model.

Various import options can be specified using parameters in a GdaParameterList object. The available options depend on the format of the imported data listed here:

- "SEPARATOR" (string, CVS import only): specifies the separator to consider

- "ESCAPE_CHAR" (string, CVS import only): specifies the character used to "escape" the strings contained between two separators

- "ENCODING" (string, CVS import only): specifies the character set used in the imported data

- "TITLE_AS_FIRST_LINE" (boolean, CVS import only): TRUE to specify that the first line of the imported data contains the column names

- "GDA_TYPE_<col number>" (gda type, CVS import only): specifies the requested GDA type for the column numbered "col number"

- "DBMS_TYPE_<col number>" (string, CVS import only): specifies the requested DBMS type for the column numbered "col number"; if the DBMS type is listed in the dictionary used by the created model, then the GDA type is set in accordance

## Details

### GdaDataModelImport

    typedef struct _GdaDataModelImport GdaDataModelImport;

### GdaDataModelImportClass

    typedef struct {
    	GdaObjectClass             parent_class;
    } GdaDataModelImportClass;

### GdaDataModelImportPrivate

    typedef struct _GdaDataModelImportPrivate GdaDataModelImportPrivate;

### gda_data_model_import_new_file ()

    GdaDataModel* gda_data_model_import_new_file
                                                (const gchar *filename,
                                                 gboolean random_access,
                                                 GdaParameterList *options);

Creates a new GdaDataModel object which contains the data stored in the `data` string.

<b>Important note:</b> the `data` string is not copied for memory efficiency reasons and should not therefore be altered in any way as long as the returned data model exists.

`filename` : |
`random_access` : |
`options` : |
Returns : | a pointer to the newly created GdaDataModel.

### gda_data_model_import_new_mem ()

    GdaDataModel* gda_data_model_import_new_mem (const gchar *data,
                                                 gboolean random_access,
                                                 GdaParameterList *options);

`data` : |
`random_access` : |
`options` : |
Returns : |

### gda_data_model_import_new_xml_node ()

    GdaDataModel* gda_data_model_import_new_xml_node
                                                (xmlNodePtr node);

Creates a new GdaDataModel and loads the data in `node`. The resulting data model can be accessed in a random way.

`node` : | an XML node corresponding to a <data-array> tag
Returns : | a pointer to the newly created GdaDataModel.

### gda_data_model_import_get_errors ()

    GSList*     gda_data_model_import_get_errors
                                                (GdaDataModelImport *model);

Get the list of errors which `model` has to report. The returned list is a list of GError structures, and must not be modified

`model` : | a GdaDataModelImport object
Returns : | the list of errors, or `NULL`

### gda_data_model_import_clean_errors ()

    void        gda_data_model_import_clean_errors
                                                (GdaDataModelImport *model);

Clears the history of errors `model` has to report

`model` : | a GdaDataModelImport object

## Properties

### The "`data`" property

      "data"                 gchararray            : Read / Write / Construct Only

Default value: NULL

### The "`filename`" property

      "filename"             gchararray            : Read / Write / Construct Only

Default value: NULL

### The "`options`" property

      "options"              gpointer              : Read / Write / Construct Only

### The "`random-access`" property

      "random-access"        gboolean              : Read / Write / Construct Only

Default value: FALSE

### The "`xml-node`" property

      "xml-node"             gpointer              : Read / Write / Construct Only