Last active
August 29, 2015 14:02
-
-
Save chapter09/97b427050f0a74998b08 to your computer and use it in GitHub Desktop.
compress reference.bib by leaving only one author on the list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
import re | |
in_fd = open('reference.bib', 'r') | |
out_fd = open('test.bib', 'a') | |
p = '\{(.*)\}' | |
for line in in_fd.readlines(): | |
if line.find('author') > -1 or line.find('AUTHOR') > -1: | |
nl = "\tauthor = {"+ re.search(p, line).group(1).split(" and ")[0]+"{\,}et.al},\n" | |
out_fd.write(nl) | |
else: | |
out_fd.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment