Generated BibTex files can not be parsed with Jabref

Issue #55 resolved
Former user created an issue

The generated BibTex files from Pybtex can not be parsed with Jabref. This is because Jabref expects the key of each entry to be on the same line as the type of the entry. Apparently Jabref does not support leading white characters before the key.

To fix this, I propose to modify the way the key is written in pybtex

Instead of having @​book{ key_of_thebook, ... } one should have

@​book{key_of_thebook, ... }

Here is a patch for file pybtexdatabaseoutputbibtex.py It replaces line 116 to 119 for key, entry in bib_data.entries.iteritems(): stream.write(u'@​%s' % entry.type) stream.write(u'{%s' % key) #for role in ('author', 'editor'):

Below is a simple that reproduces the bug with A.bib

@​MISC{XY, title = {John Doe's Book}, author = {John Doe}, file = {johnDoe.pdf:johnDoe.pdf:pdf}, }

from pybtex.database.input import bibtex as bibtexR from pybtex.database.output import bibtex as bibtexW

fileToParse = 'A.bib' fileToWrite = 'B.bib' parser = bibtexR.Parser() bib_data = parser.parse_file(fileToParse) writer = bibtexW.Writer() writer.write_file(bib_data, fileToWrite)

Comments (2)

  1. Andrey Golovizin

    Done in trunk, thanks.

    You should file a bug against Jabref however, because BibTeX reads such files correctly, without any warnings.

  2. Log in to comment