Re: isi capital letters
"Frédéric Gobry" <[email protected]> Mon, 2 Oct 2006 15:50:52 -0700
| Newsgroups | gmane.comp.gnome.apps.pybliographer |
|---|---|
| Message-ID | <[email protected]> |
Dumb me. 2006/10/2, Frédéric Gobry <[email protected]>: > Something like that, for pyblio 1.3. > > 2006/10/2, Frédéric Gobry <[email protected]>: > > > Maybe this is not a right forum to ask but I will try any way - running > > > out of ideas. I import ISI files to my pybliographer bibtex data base. > > > Does anyone have a solution on how to change capital letters in the > > > author names (written like JONES and not Jones) from older publications > > > from isi - writing a awk program could be one solution, no time to do > > > that. I would like to change this in existing bibtex file and not during > > > import. > > > > Sure, you can easily script that. If you still haven't solved your > > problem, just send me an example file so that I can write some sample > > code to run against it. > > > > -- > > Frédéric > > > > > -- > Frédéric > > > -- Frédéric ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Pybliographer-general mailing list Pybliographer-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/pybliographer-general
+cap.py
(text/x-python, 722 B)
from Pyblio import Store, Registry
import sys
bib = sys.argv[1]
Registry.parse_default()
# Create a BibTeX db
schema = Registry.getSchema('org.pybliographer/bibtex/0.1')
db = Store.get('memory').dbcreate(None, schema)
# parse the file into it
from Pyblio.Parsers.Semantic.BibTeX import Reader, Writer
r = Reader()
r.parse(open(bib), db)
# Fix the authors
def nice_author(author):
last = author.last
if last.upper() == last:
author.last = last[0] + last[1:].lower()
return author
for key, rec in db.entries.iteritems():
if 'author' not in rec:
continue
rec['author'] = [nice_author(au) for au in rec['author']]
db[key] = rec
# print the result
w = Writer()
w.write(sys.stdout, db.entries, db)