arrow-left

All pages
gitbookPowered by GitBook
1 of 3

Loading...

Loading...

Loading...

Import

circle-exclamation

This help page should describe the menu File -> Import (and the various file formats available).

Please, populate this page. Visit our page about .

See also:

how to edit a help page
Custom import filterschevron-right
Import inspection windowchevron-right
Exportchevron-right
Custom export filterschevron-right

Custom import filters

circle-exclamation

This information is outdated. Please help to improve it (how to edit a help page).

JabRef allows you to define and use your own importers, in very much the same way as the standard import filters are defined. An import filter is defined by one or more Java classes, which parse the contents of a file from an input stream and create BibTex entries. So with some basic Java programming, you can add an importer for your favorite source of references or register a new, improved version of an existing importer. Also, this allows you to add compiled custom importers that you might have obtained e.g. from GitHub without rebuilding JabRef (see "Sharing your work" below).

Custom importers take precedence over standard importers. This way, you can override existing importers for the Autodetect and Command Line features of JabRef. Custom importers are ordered by name.

hashtag
Adding a custom import filter

Make sure, you have a compiled custom import filter (one or more .class files as described below) and the class files are in a directory structure according to their package structure. To add a new custom import filter, open the dialog box Options → Manage custom imports, and click Add from folder. A file chooser will appear, allowing you to select the classpath of your importer, i.e. the directory where the top folder of the package structure of your importer resides. In a second file chooser, you select your importer class file, which must be derived from ImportFormat. By clicking Select new ImportFormat Subclass, your new importer will appear in the list of custom import filters. All custom importers will appear in the File → Import → Custom Importers and File → Import and Append → Custom Importers submenus of the JabRef window.

Please note that if you move the class to another directory you will have to remove and re-add the importer. If you add a custom importer under a name that already exists, the existing importer will be replaced. Although in some cases it is possible to update an existing custom importer without restarting JabRef (when the importer is not on the classpath), we recommend restarting JabRef after updating a custom-importer. You can also register importers contained in a ZIP- or JAR-file, simply select the Zip- or Jar-archive, then the entry (class-file) that represents the new importer.

hashtag
Creating an import filter

For examples and some helpful files on how to build your own importer, please check our download page.

hashtag
A simple example

Let us assume that we want to import files of the following form:

In your favorite IDE or text editor create a class derived from ImportFormat that implements methods getFormatName(), isRecognizedFormat and importEntries(). Here is an example:

Note that the example is in the default package. Suppose you have saved it under /mypath/SimpleCSVImporter.java. Also, suppose the JabRef-2.0.jar is in the same folder as SimpleCSVImporter.java and Java is on your command path. Compile it using a JSDK 1.4 e.g. with

Now there should be a file /mypath/SimpleCSVImporter.class.

In JabRef, open Options → Manage custom imports and click Add from folder. Navigate to /mypath and click the Select ... button. Select the SimpleCSVImporter.class and click the Select ... button. Your importer should now appear in the list of custom importers under the name "Simple CSV Importer" and, after you click Close also in the File → Import → Custom Importers and File → Import and Append → Custom Importers submenus of the JabRef window.

hashtag
Sharing your work

With custom importer files, it's fairly simple to share custom import formats between users. If you write an import filter for a format not supported by JabRef, or an improvement over an existing one, we encourage you to post your work on our GitHub page. We'd be happy to distribute a collection of submitted import files or to add to the selection of standard importers.

1936;John Maynard Keynes;The General Theory of Employment, Interest and Money
2003;Boldrin & Levine;Case Against Intellectual Monopoly
2004;ROBERT HUNT AND JAMES BESSEN;The Software Patent Experiment
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import net.sf.jabref.logic.importer.Importer;
import net.sf.jabref.logic.importer.ParserResult;
import net.sf.jabref.logic.util.FileExtensions;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.BibtexEntryTypes;

public class SimpleCSVImporter extends Importer {

    @Override
    public String getName() {
        return "Simple CSV Importer";
    }

    @Override
    public FileExtensions getExtensions() {
        return FileExtensions.TXT;
    }

    @Override
    public String getDescription() {
        return "Imports CSV files, where every field is separated by a semicolon.";
    }

    @Override
    public boolean isRecognizedFormat(BufferedReader reader) {
        return true; // this is discouraged except for demonstration purposes
    }

    @Override
    public ParserResult importDatabase(BufferedReader input) throws IOException {
        List<BibEntry> bibitems = new ArrayList<>();

        String line = input.readLine();
        while (line != null) {
            if (!line.trim().isEmpty()) {
                String[] fields = line.split(";");
                BibEntry be = new BibEntry();
                be.setType(BibtexEntryTypes.TECHREPORT);
                be.setField("year", fields[0]);
                be.setField("author", fields[1]);
                be.setField("title", fields[2]);
                bibitems.add(be);
                line = input.readLine();
            }
        }
        return new ParserResult(bibitems);
    }
}
javac -classpath JabRef-2.0.jar SimpleCSVImporter.java

Import inspection window

hashtag
Purpose

When you import new entries from a supported reference format or fetch entries directly from the Internet, the inspection window allows you to select the entries you want to keep, to avoid adding duplicated entries, and to perform some simple operations like generating citation keys for the entries or adding them to groups. If you are importing into an existing database, it is often easier to perform these operations before they are mixed in between the entries of your database.

hashtag
The inspection window

Entries are first shown in the inspection window. Note that, if this takes too long (for example), you can click on the button Stop at the bottom of the window.

Once the entries displayed in the inspection window, none of them have been added to one of your databases yet.

By default, all the entries are selected for importation, as shown by the checked boxes in the Keep column. You can select/unselect an entry by clicking on these checkboxes. On the left panel, buttons allow you to Select all the entries for importation, or to Deselect all the entries.

A left-click on an entry (out of the check box and icons) let you choose it. It displays a preview of the entry below the entry table. As usual, you can choose several entries by using the Shift or the Ctrl keys. Then, pushing the button Delete on the left panel will remove the chosen entries from the table.

A right-click on an entry displays a drop-down menu which allows you to:

  • delete the entry

  • add the entry to a group

  • link a local file to the entry

hashtag
Duplicated entries

Potential duplicates are pointed out by an icon in the second column. A click on this icon allows you to . A button on the left panel allows you to Deselect all duplicates (without inspection).

hashtag
Citation key generation

On the left panel, if the box Generate keys is checked, keys will be automatically generated on import. You can also choose to generate the keys now by clicking on the button Generate now.

hashtag
Import into the database

Once you are done with the entry selection, you can add these entries to your database by clicking on OK at the bottom of the window. Alternatively, you can Cancel the import.

download the file corresponding to the entry
  • automatically set file links to the entry

  • attach an URL to the entry

  • check the similarities
    Screenshot of the inspection window