.. _import:

CSV import
==========

PortaBase can import rows of data from CSV (Comma-Separated Value) files.  This allows you to import data exported from a spreadsheet or another database program.  To do this:

1. Open the PortaBase file you want to import the data into.  If you wish to import the data into a new file, create a new file and define a column structure that matches that of the data to be imported.

2. From the "File" menu in the :ref:`data viewer <data_viewer>`, select "Import".  A file dialog will open which allows you pick the CSV file you want to import from.  The CSV file must have the same number of columns as the open database file, and the values in those columns must be appropriate for the specified column types.  You may specify the encoding of the text file in order to import non-ASCII characters correctly; the default is UTF-8 (which supports text in many languages), but you may also choose Latin-1 (which is used by most software configured for use primarily with Western European languages).

3. The rows in the imported file are added to the database.  Rows from other files can be added by repeating this process, or another copy of the same rows can be added by importing the same file again.

Notes:

* Boolean fields must have a value of either 0 or 1.

* Date fields may be formated as YYYYMMDD, YYYY/MM/DD, YYYY-MM-DD, or YYYY.MM.DD.

* Time fields may be formated as HH:MM:SS, HH:MM:SS AM, HH:MM, HH:MM AM, or the number of seconds past midnight.  Blank or -1 values are interpreted as "None".

* Calculation fields may be left as 0 or whatever; the actual values will be calculated during import.

* Image fields should contain either nothing (for no image loaded) or the relative or absolute path to a suitable image file.
