The latest revision of the RIS specs includes some new fields (most notably, DA for "date"), as well as some new rules for old fields.

According to the new specs, only the year of publication YYYY can be put in the PY field, whereas the complete YYYY/MM/DD/etc gets put into the new DA field. Biblio 6.x-1.18 doesn't seem to know about the DA field. That wasn't a problem until recently, when Zotero (which I use to export my RIS files) adopted the new specs for its export translator, so I'm now losing most of my date info when I import an RIS file into Biblio.

Is there any timeline for updating the RIS import functionality of Biblio to match the new specs?

Comments

pkiff’s picture

I've been having some frustrations with different versions of the RIS format as well, but didn't realize until now that the PY field had been changed the way you indicated, and the DA field had been added.

One quick-and-dirty workaround that you might try is simply to replace the DA tag with Y1. To do this, you would take your RIS exported plain text file, and do a find and replace on the text "DA -" (that's with 2 spaces before the hyphen) and replace it with "Y1 -". Then try your import again. If necessary, you could also find and replace the PY field so you don't end up with a conflict. Just replace "PY -" with "PZ -" (or whatever, just so long as it is not a recognized tag).

The RIS parser in all versions of biblio (so far) treats both PY and Y1 as legitimate tags, and it will parse both of them the same way: it will take the first chunk of text (up to the first slash) and put it in the "biblio_year" field and then it will put the entire text (including the year), unaltered, into the "biblio_date" field. So you should get both the year of publication and date of publication fields by just parsing the DA field. Note that the biblio_date field is actually a text field, so whatever format you use in Zotero should work fine.

To fix this in the biblio code itself, you would need to edit the ris_parser.inc file in 6.x-1.18, and replace this code:

<?php
        case 'Y1' :
        case 'PY' :
          $node['biblio_year'] = ($end = strpos($value, "/")) ? substr($value, 0, $end) : $value;
          $node['biblio_date'] = $value;
          break;
/?>

with something that added a DA case and then took into account the possibility that an RIS export file might contain both DA and PY.

Here is some untested code to get a start on this:

<?php
        case 'Y1' :
        case 'PY' :
        case 'DA' :
          $node['biblio_year'] = ($end = strpos($value, "/")) ? substr($value, 0, $end) : $value;
          if (empty ($node['biblio_date'])) { // if biblio_date not yet assigned
            $node['biblio_date'] = $value; // then assign the value of the current tag to it
          } 
          else if (strlen($value) > strlen($node['biblio_date'])) { // otherwise, check if current tag is longer than previous assignment
            $node['biblio_date'] = $value; // then assign the value of the current tag to it
          }
          break;
/?>

Repeat: not tested!

Because it is possible for a valid RIS field to have the tags in any order, there is no way to be sure that an RIS file will have DA after PY, or if it will have only one or the other present. So, the basic idea of the code above is to use the length of the field as an indicator of whether it contains a full date or only a year.

Whatever code is inserted here has to be able to work for files that export using the original RIS format (where PY contains the full date separated by slashes) as well as the new format (where PY contains only the year and where DA now contains the full date separated by slashes).

Phil.

mjt772’s picture

@pkiff Thanks for the advice. I'm hesitant (as I think we all are) to hack a contributed module unless it's absolutely necessary. In my case, I've been able to get away with employing a workaround like the one you described (manually performing a series of replacement operations on the RIS files before I import them via Biblio.) That seems to be sufficient for my purposes for now, but I hope that the parser will be updated to handle the new RIS specs at some point (at least in D7, if not in D6).

- Michael

cricket’s picture

I am having a similar problem with publication dates using RIS.

My citation has a publication date value of "1920-1940" and to get
a display value I use:

Y1 - "1920-1940"

But then I also have to use a dummy PY value to get the record to load:

PY - 1920

This sort-of-works. If anyone has a better suggestion, please post it.

cheers!
cricket!

liam morland’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This version is no longer maintained. If this issue is still relevant to the Drupal 7 version, please re-open and provide details.