Re: [Refdb-users] Endnote to RIS to RefDB troubles
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mar...@mh...> - 2003-04-28 23:14:03
|
Hi Bruce, the current script expects both the SP and EP tags, so please leave them in (it's a tad easier to deal with for me). On the dates: Are they predictable, sort of? That is, can I always expect to find something like "December 1" in Y2 or could it as well be "Dec 1" or whatever? I could do a translation if these dates show up in a consistent format, or at least a small number of discernible formats. Assuming that Y2 may contain random stuff, the script attached below should work now (I'll put it in CVS shortly, and it'll have nice command-line parameters to select the encoding, and it'll read a config file and such, eventually). It requires Text::Iconv from your favourite CPAN mirror. I run it here like this, using your Mac-style test file: tr "\r" "\n" < endnote_export.ris | en2ris.pl > out.ris On a Mac you may have to run it like this instead: en2ris.pl < endnote_export.ris | tr "\r" "\n" > out.ris regards, Markus Bruce D'Arcus writes: > > On Monday, April 28, 2003, at 04:33 PM, Markus Hoenicka wrote: > > > en2ris.pl fiddles only with the tags (I forgot to take care of the > > dates, though). > > And on the dates, will my suggested solution work for the export > filter? I will plan to keep (and extend) the SP and EP pages thing.... > > Bruce en2ris.pl --8<------ #!/usr/bin/perl use Text::Iconv; my $last_tag = "TY - "; my $PY = ""; my $Y2 = ""; my $converter = Text::Iconv->new("MacRoman", "UTF-8"); while (<>) { if ($_ =~ /^(.. - )/) { $last_tag = $1; } elsif ($last_tag eq "KW - ") { print $last_tag . $_; $_ = ""; } if ($_ =~ /^SP - /) { $_ =~ s/^SP - (.*)-.*/SP - $1/; } elsif ($_ =~ /^EP - /) { if ($_ =~ /^EP - .*-.*/) { $_ =~ s/^EP - .*-(.*)/EP - $1/; } else { $_ = ""; } } elsif ($_ =~ /^PY - /) { chomp $_; $PY = substr($_, 6); $_ = ""; } elsif ($_ =~ /^Y2 - /) { chomp $_; $Y2 = substr($_, 6); $_ = ""; } elsif ($_ =~ /^ER - /) { # dump pubyear string print $converter->convert("PY - $PY$Y2\n"); $PY = ""; $Y2 = ""; } print $converter->convert("$_"); } --8<------ -- Markus Hoenicka mar...@ca... (Spam-protected email: replace the quadrupeds with "mhoenicka") http://www.mhoenicka.de |