# Importing and Exporting Data

&bookcase; is able to import and export a wide variety of data.

## Importing Data

&bookcase; offers three different actions when importing data. Replace collection indicates the current collection should be closed, and a new one created with the data from the imported file. Append collection tells &bookcase; to add all the entries in the imported collection to the current one, and to add any fields which don't currently exist. The Merge collection action is the same as appending, except that each imported entry is compared to the current ones, and any identical entries are skipped. Future plans include an improved heuristic for identifying matching entries, but currently, they must be identical for every field.

### Importing Bookcase Data

Other &bookcase; data files may be imported. Replacing the current collection by importing a &bookcase; file is the same thing as just opening the file itself. The value of importing &bookcase; data is primarily for appending or merging two collections together.

### Importing CSV Data

Comma-separated values (CSV) are a common way of importing and exporting tabular data. Each field value is separated by a comma, with one entry per line. The field titles may be included in the first line. The CSV importer is not limited to using a comma as the separator. Any character or string may be used.

The CSV Import Dialog
The CSV Import Dialog

The CSV Import Dialog

First, select the type of collection that you are importing. If you are appending or merging to your open collection, the type is limited to your current collection type. If the first line of the CSV file contains the field titles, click the checkbox and the importer will automatically compare the titles against the fields in the current collection. If a field title matches, the header for that column changes to show that the column has been assigned to that field. If the file uses a delimiter other than a comma, be sure to change that option accordingly.

In order for &bookcase; to properly import the file, it must know which field corresponds to each column. If the column only has a number in the header, the data in that column will not be imported. You should assign fields to each column by selecting a column, either by clicking in it or changing the column number itself, then selecting the field to assign from the dropdown list and clicking the Set button. If you need to add a new field to the collection, the last item in the dropdown list opens the &fields-dialog;.

Only the first five lines of the imported CSV file are shown in the dialog.

### Importing Bibtex Data

Bibtex is a bibliography format used with the LaTeX document preparation system. Various type of bibliographic references may be included in the file. &bookcase; imports bibtex files as a Bibliographic collection.

If the bibtex importer encounters fields in the file which are not in the default bibliography collection, they are added as Simple Text fields, with two exceptions. If the field value contains more than 100 characters, it becomes a Paragraph field. If the field value appears to contain a &URL; or a file reference, then a URL field is created. &bookcase; uses an internal copy of the btparse library for parsing the bibtex files.

### Importing Bibtexml Data

Bibtexml is an XML representation of bibtex data, and the data from the imported bibtexml file is treated in the same way as bibtex data would be.

### Importing XML Data via XSLT

Any XML file may be imported into &bookcase; provided an XSL stylesheet is available to convert the file to &bookcase; format. &bookcase; automatically loads the stylesheet and performs the XSLT processing needed to load the file.

## Exporting Data

To be written...

### Exporting XML

The file format for &bookcase; data is a zipped XML file. Exporting to XML merely skips the zip compression. Images may be included in the XML file as base64-encoded data in image elements.

### Exporting HTML

### Exporting CSV

### Exporting Pilot-DB

### Exporting Bibtex

### Exporting Bibtexml

### Exporting XML via XSLT