# Importing and Exporting Data

&appname; is able to import and export a wide variety of data files, as well as search various Internet sites for information.

## Importing from the Internet

&appname; is able to search various Internet sites using the &fetch-dialog;. Entries may be directly imported and added to your current collection. The various providers are configured via the Data Sources Options.

Searches may use four different criteria: Title, Person, ISBN, or Keyword. Not all criteria are available for certain data sources. Once a search is initiated, the Search button becomes Stop which will end a search. As results are found, they are added to the list directly under the search box, where selecting an item will show the result without adding it to the collection. Clicking the Add Entry button will add all the selected items to your collection. Clicking Clear will remove all the current results and reset the search.

The &appname; &fetch-dialog;
The &appname; &fetch-dialog;

The &appname; &fetch-dialog;

Only entries that match the current collection type will be found. The Description column provides additional information about the entry, in order to differentiate between videos on different formats, or books in different bindings. Once an entry is successfully added to the collection, an icon is added to the first column in the list.

To facilitate the use of barcode scanners, searches can include multiple ISBN values. Selecting the Multiple ISBN search checkbox will disable the search box and enable the Edit ISBN list... button, which will open a multi-line text entry box. Each ISBN should be entered on a line by itself. After closing the box, each ISBN will be validated for correct formatting. The ISBN validation is able to convert 13-digit EAN values, as well as full UPC codes, to the proper formatting. The ISBN list may also be read from a text file.

## Importing Data

&appname; 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 &appname; 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, except for music collections, they must be identical for every field. Music collections compare the artist and album only, and the tracks are merged for matching entries. The audio file importer is able to correctly build track lists by merging entries.

### Importing &appname; Data

Other &appname; data files may be imported. Replacing the current collection by importing a &appname; file is the same thing as just opening the file itself. The value of importing &appname; 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 &appname; 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 Assign Field 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 Audio CD Data

&appname; is able to use the freedb.org service to lookup information about a CD, including the track list.

### Importing Audio File Metadata

&appname; is able to scan a directory and read the tags for common audio file formats, such as `mp3` and `ogg`. The songs are entered in a music collection, where each entry is an album. If the song files contain the track number, the song name is inserted in the correct spot in the track list. The artist and genre information is also added to the entry. If the song tags contain comments, they are appended to the comments field in the entry, preceded by the file name.

In addition, if a directory contains a `.directory` file and the directory name matches an album title, the `Icon` entry in the desktop file is used as the cover image for the album.

The audio file metadata importer can recursively scan a directory to find all audio files in any subdirectory, though symbolic links are not followed.

### Importing Alexandria Libraries

Alexandria is a book collection manager for the Gnome desktop environment. The importer offers a choice of importing any of the libraries found in `$`HOME`/.alexandria/`.

### 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. &appname; 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. &appname; 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 MODS Data

MODS is a format for representing various types of media collections. Currently, only books may be imported to &appname;.

### Importing RIS Data

The RIS format is a bibliographic file format used by Reference Manager and others.

### Importing &xml; Data via XSLT

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

## Exporting Data

When exporting the data in the collection, the entry values may be exported as entered, or with the automatic formatting provided by &appname;. Additionally, the export may be limited to the currently selected entries of the collection as well, where the statusbar shows the number of selected entries.

Exported text files, such as Bibtex or CSV, may use the Unicode (UTF-8) character encoding, or the current locale of the operating system.

General Export Options
General Export Options

General Export Options

### Exporting &xml;

The file format for &appname; data is a zipped &xml; file. Exporting to &xml; merely creates the &xml; file without zipping it. Images may be included in the &xml; file as base64-encoded data in an image element.

### Exporting HTML

The HTML export uses the `tellico2html.xsl` stylesheet. Images are exported to a folder with the same name as the exported HTML file with `-images` appended.

The default format is similar to the printed output, and allows various options for modifying the HTML. Field headers may be printed at the top of each column, but unfortunately, &kde; does not yet allow the table headers to be be repeated on each page. The entries may be grouped as in the &group-view;, as well.

Additionally, individual files may be created for each entry in the collection, with links created in the top-level HTML file. The entry files will be created in a folder with the same name as the exported HTML file, with `-entries` appended. The entry HTML files will use the current stylesheet template, as shown in the &entry-view;.

HTML Export Options
HTML Export Options

HTML Export Options

### Exporting CSV

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 as headers in the first line. Any character or string other than a comma may also be used to delimit the fields.

CSV Export Options
CSV Export Options

CSV Export Options

### Exporting Pilot-DB

TBD

### Exporting Bibtex

When exporting to Bibtex, the field values may be escaped with braces or quotation marks.

### Exporting Bibtexml

TBD

### Exporting &xml; via &xslt;

Finally, &appname; is able to process its internal &xml; representation of the collection data through an external XSL stylesheet before exporting. This type of export may be useful for generating text reports or other file types.