/[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

Contents of /casopisi/marc2stream.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Sun Oct 27 21:20:10 2002 UTC (21 years, 5 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +9 -6 lines
File MIME type: text/plain
brown bag bug: verbose output destroyed everything...

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

  ViewVC Help
Powered by ViewVC 1.1.26