MUIbase Support This Project
programmable relational database
with graphical user interface
This page is also available in deutsch français

Documentation

Below documentation is part of the MUIbase dictribution and is also available in PDF.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

13. Import and Export

For sharing your records with other databases, MUIbase offers a way to import and export records from and to other databases. Import and export is done by reading and writing text files. The text files must follow a special format described in the next section.


13.1 File Format

For importing records into MUIbase, all records of a table should be in a single text file. If records of several tables are to be imported, they should be in separate import files, one for each table.

An import file consists of lines and columns. Lines are separated by a record delimiter, columns by a field delimiter. The delimiters can be specified in the import and export dialog. Since a record field itself may contain such a delimiter, double quotes can be used around all fields for escaping delimiters.

The import file should be of the following structure:

  • The first line contains the field names. For each name the table where the records are imported to must contain an attribute with the exact same name. In case no matching attribute is found for a given name, the import fails with an error message.
  • The following lines contain one record each. Since all fields are given as strings, they are converted automatically to the type of the destination attribute. For attributes of type Boolean, the field must be either NIL or TRUE (case insensitive), otherwise an error message is generated. For attributes of type choice the exact label string must be specified (case sensitive). For reference attributes the record number starting with 1 must be specified. For all other types a value of NIL is used if the field cannot be converted to the required type.
  • If you decide to use double quotes then all record fields including the line containing the field names must be surrounded by double quotes.


13.2 Sample Import File

The following sample import file uses \n and \t for record and field delimiters and double quotes around all fields. The file can be imported into a table with the following attributes:

  • Name (string)
  • NumChildrens (integer)
  • Feminine (Boolean)
  • Job (choice)
  • Notes (memo)

 

"Name"	"NumChildrens"	"Feminine"	"Job"	"Notes"
"Janet Jackson"	"???"	"TRUE"	"Musician"	"Latest CD: The velvet rope"
"Bernt Schiele"	"???"	"NIL"	"Scientist"	"Research interests:
Robotics, Autonomy and Computer Vision"
"Gerhard"	"0"	"NIL"	"Precision mechanic"	""


13.3 Importing Records

To import records into the active table select menu item `Table - Import records'. This will open a window containing

  • a string field for entering the import filename. To the right of this field you find three buttons. Click on the first one to open a file dialog for choosing the filename. The second button starts an external viewer with the entered filename while the third button starts an editor for editing the file contents.
  • two string fields for entering the record and field delimiters. You can enter a single character or an escape code by typing \n, \t, \f, \??? (octal code), or \x?? (hex code). Delimiter characters must be 7bit ASCII characters.
  • a field `Double quotes' that can be checked to specify that the fields are surrounded by double quotes.
  • a field `Overwrite records' that if selected will overwrite existing records with the imported data. This can be useful in case you want to keep the existing records (e.g. because there are references to them) but update them with new information.
  • two buttons `Import' and `Cancel' for leaving the window.

If you press the `Import' button, MUIbase will load the specified file and import all found records. If everything went fine and new records were created in the table, MUIbase asks after the import process if you really want to add the newly imported records to the table. At this point you can still cancel the operation. Overwritten records, however, can only be recovered by reverting the project.

If an error occurs while reading the import file then an error message is shown.

If you need a more sophisticated import routine it is recommended to write your own import routine as a MUIbase program.


13.4 Exporting Records

To export records from the active table select menu item `Table - Export records'. This will open a window containing

  • a string field for entering the export filename. Right to this field you find a pop-up button to open a file dialog for choosing the filename.
  • two string fields for entering the record and field delimiters. You can enter a single character or an escape code by typing \n, \t, \f, \??? (octal code), or \x?? (hex code).
  • a field `Double quotes' that can be checked to specify that the fields should be surrounded by double quotes.
  • a field `Filter'. If checked only the records that match the currently installed record filter are written to the export file.
  • two buttons `Export' and `Cancel' for leaving the window.

After you pressed the `Export' button, MUIbase will open the specified file and write out the records including a header line containing the attribute names. The export feature always writes all attribute fields of a table to the export file.

For a more customized export routine, you can use MUIbase' query editor (see Data retrieval) or you write your own export function as a MUIbase program.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated on September, 11 2016 using texi2html