import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
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 {
public String getName() {
return "Simple CSV Importer";
public FileExtensions getExtensions() {
return FileExtensions.TXT;
public String getDescription() {
return "Imports CSV files, where every field is separated by a semicolon.";
public boolean isRecognizedFormat(BufferedReader reader) {
return true; // this is discouraged except for demonstration purposes
public ParserResult importDatabase(BufferedReader input) throws IOException {
List<BibEntry> bibitems = new ArrayList<>();
String line = input.readLine();
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]);
return new ParserResult(bibitems);