/[webpac-proto]/casopisi/marc2stream.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /casopisi/marc2stream.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sat Oct 26 21:22:43 2002 UTC (21 years, 6 months ago) by dpavlin
Branch: MAIN
Changes since 1.1: +2 -1 lines
File MIME type: text/plain
move verbouse output at start

1 dpavlin 1.1 #!/usr/bin/perl -w
2    
3     use strict;
4     use MARC;
5     use URI::Escape;
6     require "../common.pm";
7    
8     my $file = shift @ARGV;
9     my $index = shift @ARGV|| die "Usage: $0 [marc file] [index dir]";
10    
11     my %id_stored; # to aviod duplicates
12    
13     my $x = new MARC;
14     my $nr = $x->openmarc( { file => $file, format => 'usmarc' }) ||
15     die "Can't open MARC file '$file'";
16    
17 dpavlin 1.2 print "file: '$file' 773 t: ",$x->getfirstvalue({record=>$x->nextmarc(1),field=>773,subfield=>'t',delimiter=>" "}),"\n";
18     $x->nextmarc(-1);
19 dpavlin 1.1
20     my $dir = open_data_files($index);
21     my $last_tell=0;
22    
23     print MPS "M working...\n";
24    
25     my $rec;
26    
27     while ($x->nextmarc(1)) {
28     # print $x->output({format=>'ascii'}); # FIX
29    
30     $rec = $x->marc_count();
31     # print $x->getfirstvalue({record=>$rec,field=>245,subfield=>'a',delimiter=>" "}),"<--\n";
32     my $bib = "";
33     my $mps = "";
34    
35     sub getfld {
36     my ($f,$s) = @_;
37     my $out = $x->getfirstvalue({record=>$rec,field=>$f,subfield=>$s,delimiter=>" "});
38     # print "$f/$s:$out\n";
39     return $out;
40     }
41    
42    
43     my $id = getfld(856,'u');
44    
45     $bib .= "%tip Èasopis\n";
46     $bib .= "%tip on-line\n";
47     # url
48     $bib .= "%856 ".getfld(856,'u')."\n";
49    
50     # naslov
51     $bib .= "%200+ ".getfld(245,'a')."\n";
52     $mps .= mps_expand(2,getfld(245,'a'));
53    
54     # izdavanje
55     $bib .= "%210+ ".getfld(773,'d')."\n";
56     $mps .= mps_expand(3,getfld(773,'d'));
57    
58     # issn
59     my $issn = getfld('022','a');
60     if ($issn) { # ISSN can be missing?
61     $bib .= "%ISSN $issn\n";
62     $mps .= mps_expand(13,$issn);
63     }
64    
65     $bib .= "%992 ".getfld(856,'3')."\n";
66    
67     # tip
68     $mps .= mps_expand(17,"on-line casopis");
69    
70     $mps .= "H ".getfld(245,'a')." &lt;i&gt;(on-line, ".getfld(773,'t').")&lt;/i&gt;\n";
71    
72     if (defined $id && ! defined $id_stored{$id}) {
73    
74     print R $bib."\n";
75     $mps .= "T document text/plain ".(tell(R) - $last_tell)." $dir/bib $last_tell ".tell(R)."\n";
76     $last_tell=tell(R);
77     print R "\n";
78     $mps .= "E\n";
79     print S $mps;
80     print MPS $mps;
81    
82     $id_stored{$id}++;
83     } else {
84     print ".";
85     }
86     }
87    
88     print S "M over and out\nX\n";
89     print MPS "M over and out\nX\n";
90     close(MPS);

  ViewVC Help
Powered by ViewVC 1.1.26