Gda.DataModelImport

g GObject.GInterface GObject.GInterface Gda.DataModel Gda.DataModel GObject.GInterface->Gda.DataModel GObject.Object GObject.Object Gda.DataModelImport Gda.DataModelImport GObject.Object->Gda.DataModelImport Gda.DataModel->Gda.DataModelImport

Subclasses:None

Methods

Inherited:GObject.Object (37), Gda.DataModel (43)
Structs:GObject.ObjectClass (5)
class new_file (filename, random_access, options)
class new_mem (data, random_access, options)
class new_xml_node (node)
  clean_errors ()
  get_errors ()

Virtual Methods

Inherited:GObject.Object (7), Gda.DataModel (27)

Properties

Name Type Flags Short Description
data-string str r/w/co String to import
filename str r/w/co File to import
options Gda.Set r/w/co Options to configure the import
random-access bool r/w/co Random access to the data model is possible
strict bool r/w/c Consider missing or too much values an error
xml-node int r/w/co XML node to import from

Fields

Inherited:GObject.Object (1), Gda.DataModel (6)
Name Type Access Description
object GObject.Object r  

Class Details

class Gda.DataModelImport(**kwargs)
Bases:GObject.Object, Gda.DataModel
Abstract:No
Structure:Gda.DataModelImportClass
classmethod new_file(filename, random_access, options)
Parameters:
  • filename (str) – the file to import data from
  • random_access (bool) – True if random access will be required
  • options (Gda.Set or None) – importing options
Returns:

a pointer to the newly created Gda.DataModel.

Return type:

Gda.DataModel

Creates a new Gda.DataModel object which contains the data stored within the filename file.

The options are the following ones:

  • For the CSV format:
    • ENCODING (string): specifies the encoding of the data in the file
    • SEPARATOR (string): specifies the CSV separator (comma as default)
    • QUOTE (string): specifies the character used as quote (double quote as default)
    • NAMES_ON_FIRST_LINE (boolean): consider that the first line of the file contains columns’ titles (note that the TITLE_AS_FIRST_LINE option is also accepted as a synonym)
    • G_TYPE_<column number> (GObject.GType): specifies the type of value expected in column <column number>
  • Other formats: no option

Note: after the creation, please use Gda.DataModelImport.get_errors() to check any error.

classmethod new_mem(data, random_access, options)
Parameters:
Returns:

a pointer to the newly created Gda.DataModel.

Return type:

Gda.DataModel

Creates a new Gda.DataModel object which contains the data stored in the data string.

Important note: 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.

classmethod new_xml_node(node)
Parameters:node (libxml2.NodePtr) – an XML node corresponding to a <data-array> tag
Returns:a pointer to the newly created Gda.DataModel.
Return type:Gda.DataModel

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

clean_errors()

Clears the history of errors self has to report

get_errors()
Returns:the list of errors (which must not be modified), or None
Return type:[GLib.Error]

Get the list of errors which self has to report. The returned list is a list of GLib.Error structures, and must not be modified

Property Details

Gda.DataModelImport.props.data_string
Name:data-string
Type:str
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY

Data to import, as a string.

Gda.DataModelImport.props.filename
Name:filename
Type:str
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY

Name of the file to import.

Gda.DataModelImport.props.options
Name:options
Type:Gda.Set
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY

Data model options.

Gda.DataModelImport.props.random_access
Name:random-access
Type:bool
Default Value:False
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY

Defines if the data model will be accessed randomly or through a cursor. If set to False, access will have to be done using a cursor.

Gda.DataModelImport.props.strict
Name:strict
Type:bool
Default Value:False
Flags:READABLE, WRITABLE, CONSTRUCT

Defines the behaviour in case the imported data contains recoverable errors (usually too many or too few data per row). If set to True, an error will be reported and the import will stop, and if set to False, then the error will be reported but the import will not stop.

New in version 4.2.1.

Gda.DataModelImport.props.xml_node
Name:xml-node
Type:int
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY

Data to import, as a pointer to an XML node (a libxml2.NodePtr).