[Biopython-dev] The 'year' attribute of parsed Medline record return empty

Jeffrey Chang jchang at SMI.Stanford.EDU
Sat Oct 13 17:26:44 EDT 2001

This is as designed.  The members of the Record class are supposed to 
mirror the information given in the MEDLARS format.  If there's no YR 
line, then the year member of the record is empty.

If you need the year member, it should be pretty simple to make a 
parser that uses it.  For example, you could do (untested):

class MyParserWithYear:
   def parse(self, handle):
     rec = Medline.RecordParser().parse(handle)
     if not rec.year:
       rec.year = rec.publication_date[:4]
     return rec


At 8:29 PM -0700 10/12/01, Chunlei Wu wrote:
>Hi, all,
>     Here is a sample code:
>print cur_record.year
>     The 'year' attribute always returns empty string,
>while 'publication_date' attribute returns the correct
>whole date string. When I looked into the __init__.py,
>I found the 'year' attr. coresponding to 'YR'
>qualifier. But 'YR' doesn't exist in most of Medline
>format record. Although we can get year-value easily
>from cur_record.publication_date[:4], I think it's
>better give the proper value to the attr of 'year'.
>Chunlei Wu
>Do You Yahoo!?
>Make a great connection at Yahoo! Personals.
>Biopython-dev mailing list
>Biopython-dev at biopython.org

More information about the Biopython-dev mailing list