Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert a BibTex bib file to Word 2010 XML?

Tags:

What's the best way to convert a Bibtex .bib file to an XML file that can be imported by MS Word 2010?

like image 801
impala79 Avatar asked Feb 21 '13 01:02

impala79


People also ask

Is BibTeX an XML?

BibTEXML is an XML representation of BibTEX data. It can be used to represent bibliographic data in XML.

How do I convert a BIB file?

Follow these easy steps to convert a BibTeX file into an Excel file with the BibTeX format converter: Click the Choose BibTeX file button above, drag and drop a file into the drop zone or copy and paste the content of your BibTeX file into the area above. Select the desired output format (Excel). Click Convert.

How do I open a BibTeX file on Windows?

If you cannot open your BIBTEX file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a BIBTEX file directly in the browser: Just drag the file onto this browser window and drop it.


3 Answers

The Java application JabRef is a great tool, I have used it successfully to export my BibTex entries to XML and imported them into Word 2013 with no problems at all.

Check it out at: http://www.jabref.org/

like image 82
Javier Isaaí Avatar answered Sep 30 '22 20:09

Javier Isaaí


Here's the solution I found.

Bibutils, available in the Ubuntu repos, provides some tools for converting BibTex to Word XML, but there was some trouble with Word not importing some of the fields properly. Here's some Python Code to do it all in one go. So far i've got it going for @article and @inproceedings entries..

#THIS REQUIRES THAT bibutils IS INSTALLED ON YOUR MACHINE

"""
Usage:
./Bib2Word2010XML.py [Input file name] [Output file name]
"""

import sys
import fileinput
import os

if __name__ == '__main__':
  #input a BibTex .bib file
  fnameIN = sys.argv[1]
  fnameOUT = sys.argv[2]

  #run bibutils functions to convert to Word XML
  os.system("bib2xml " + fnameIN + " > TEMPOUT1.xml")
  os.system("xml2wordbib TEMPOUT1.xml > TEMPOUT2.xml")
  os.system("rm TEMPOUT1.xml")

  #clean up for Word 2010 formatting
  f1 = open('TEMPOUT2.xml', 'r')
  f2 = open(fnameOUT, 'w')
  for line in f1:
    line = line.replace("ArticleInAPeriodical", "JournalArticle")
    line = line.replace("PeriodicalName", "JournalName")
    line = line.replace("Proceedings", "ConferenceProceedings")
    f2.write(line)
  f1.close()
  f2.close()
  os.system("rm TEMPOUT2.xml")
like image 28
impala79 Avatar answered Sep 30 '22 19:09

impala79


Based on impala79s' answer this one-liner worked for me using MS Word 2007. mybib.bib is the input bib file we want to convert to word format and word.xml is the output name of the file we want to save the wordbib format to. As stated above you need to install the bibutils package.

bib2xml mybib.bib | xml2wordbib | sed -e 's/PeriodicalName/PeriodicalTitle/g' -e 's/>Proceedings/>ConferenceProceedings/g' > word.xml

PS. You need bibutils package installed on your machine similarly with above answer

like image 29
Andreas Grivas Avatar answered Sep 30 '22 20:09

Andreas Grivas