Monday, November 15, 2021

Importing your EndNote Library into Zotero with PubMed IDs

I'm neurotic about integrating PubMed IDs (PMIDs) into my reference manager. They're required for NIH grants, Harvard Medical School CVs, and many journal submissions. And I'm disciplined about getting most of my references from PubMed. Exporting from PubMed ensures that my EndNote references include doi's, PMCIDs, and PMIDs. The last item is stored as an "Accession Number." I also attach pdfs of articles to each reference. I'm a huge fan of EndNote, despite the unappealing layout of X20.

Recently, I was forced to embrace Zotero. This article is not meant to be a comparison of reference management software, but I'll say it has some nice aspects that are lacking in EndNote, including (a) a price tag of zero, if you don't need much online storage, and (b) integration with Google docs (Zotero also has some major disadvantages). Fortunately, a person can transfer most of an EndNote library, including pdfs, into Zotero pretty easily...

I say "most" rather than "all" because Zotero doesn't systematically import PMIDs. It's a **huge** turnoff for someone like me because I've spent years curating my EndNote library, and I don't care to do this again from scratch. I experimented with exporting from EndNote as .ris rather than .xml files and playing with plug-ins that would auto-populate PMIDs as long as you had an article's doi. The latter works, but you have to run the plug-in one reference at a time.

I finally just toyed with the javascripts, and got the batch export/import to work exactly as I hoped, storing PMCIDs and PMIDs in the Extras field. This format is essential if you want to use the "National Library of Medicine (grant proposals with PMCID/PMID)" style. If you're a mediocre programmer like me, using EndNote on a Windows machine, and looking to transition to Zotero, you're likely to find the instructions below helpful! I'm sure I'm not the only one who struggled with this process!

Step 1. Enable your system to edit and save javascripts as javascripts

If your system is like mine, it'll save any modifications you make to a javascript file (.js) as a text file (.txt). An easy workaround is to make extensions visible and to sure your edited filename ends in ".js" rather than ".txt". Here's how to do this in Windows 10:

Step 1a: Go to the File Explorer Developer Settings (e.g., click on the Windows key, type "File Explorer," and click on "File Explorer Developer Settings")


Step 1b: Show settings for "Change settings to show file extensions"


Step 1c: Uncheck "Hide extensions for known file types"


Step 1d. Click OK

2. Modify the "translators" javascript for "Endnote XML.js" to import PMIDs

Step 2a. Find the file in your Zotero folder.

In Windows, the translator scripts are typically stored in "C:\Users\[your user name]\Zotero\translators." Find "Endnote XML.JS"


Step 2b. Copy and save the original file somewhere safe

I don't know what happens if you botch the editing of this file, but it's probably bad. Save yourself some agony and copy and paste the original version somewhere safe in case you screw something up. That way, you can copy and paste the original version back into the "translators" folder.

Step 2c. Open the file in an editor of your choice

I suggest just right-clicking on the file and opening with Notepad.

Step 2d. In the version saved in "translators," edit the importNext function to translate PMIDs

Simply copy and paste the blue text below into the function somewhere. I included a screenshot of where I stuck the code.

} else if (field == "accession-num") {
                    newItem.extra = (newItem.extra || '')
                        + `PMID: ${node.textContent}\n`;


Step 2e. Save the file, and make sure it has a ".js" file extension

My computer annoyingly turned any edited file into a ".txt" file. If you've made file extensions visible, you can simply change the ".txt" to ".js" with File Explorer.

3. Export your citations from EndNote into your Endnote.Data folder

In your EndNote library, highlight the references you want to export into Zotero. Then click File->Export and export into an .xml file using the "EndNote Export" output style. **If you want the associated attachments to export with the reference, be sure to save the .xml file in the .Data folder associated with the EndNote library. See the attached screenshot below, which I named "P" simply because I was exporting references whether the first author's name began with the letter 'p.'



4. Import the .xml file into Zotero

This step is simple: File -> Import. You'll probably only have one option to use (i.e., "A file (BibTex..."). Select the .xml file you created. I copy the files to the Zotero storage folder to simplify the syncing process, although this can take up a tremendous amount of storage on your drive. Whether to "Place imported collections and items into new collection," doesn't matter much.



Voila! You're good to go! If everything worked right, your imported references that have pdfs, PMCIDs, and PMICs should look in Zotero like the screenshot below.



Leave comments if you have any additional suggestions or questions. Also, note that these instructions may become moot when Zotero 5.1 goes live as PMID and PMCID fields will standard fields in the newer version.