This script B<is somewhat specific> to MODS export from
Faculty of Electrical Engineering and Computing
-so you might want to edit it
+so you might want to edit it (among other thing, it includes a lot
+of fields which are in Croatian).
+
+Feel free to hack this script and convert it to your own needs.
=head1 WARNING
ContentKey => '-content',
);
- my $m=$marc->createrecord();
+ my $m_cache;
- sub marc_arr {
- my $m = shift || die "no marc record?";
- my $fld = shift || die "no marc field?";
+ sub marc_add {
+ my $m_cache = \shift;
+ my $fld = shift || die "need field!";
my $sf = shift || '';
return if (! @_);
my @a;
foreach (@_) {
next if (! $_);
- push @a,$sf;
+ push @a,$sf if ($sf);
# push @a,$utf2iso->convert($_) || $_;
push @a,$_;
}
# print "storing $fld: ",join("|",@a),"\n";
- $marc->addfield({record=>$m,
- field=>$fld,
- # i1=>$i1,
- # i2=>$i2,
- value=>\@a});
+ push @{$$m_cache->{$fld}}, @a;
+
}
- marc_arr($m,'610','a',@{$ref->{subject}->{topic}});
+ my $journal = 0;
+ $journal = 1 if ($ref->{recordInfo}->{recordIdentifier} =~ m/^c-/);
+
+ marc_add($m_cache,'610','a',@{$ref->{subject}->{topic}});
my $fld = '700';
my $role = $name->{role}->{roleTerm}->{content};
next if (! $role);
if ($role eq "author") {
- marc_arr($m,$fld,'a',$name->{namePart}->{family});
- marc_arr($m,$fld,'b',$name->{namePart}->{given});
- marc_arr($m,$fld,'4',$role);
+ marc_add($m_cache,$fld,'a',$name->{namePart}->{family});
+ marc_add($m_cache,$fld,'b',$name->{namePart}->{given});
+ marc_add($m_cache,$fld,'4',$role);
# first author goes in 700, others in 701
$fld = '701';
} elsif ($role eq "editor" or $role eq "illustrator") {
- marc_arr($m,'702','a',$name->{namePart}->{family});
- marc_arr($m,'702','b',$name->{namePart}->{given});
- marc_arr($m,'702','4',$role);
+ marc_add($m_cache,'702','a',$name->{namePart}->{family});
+ marc_add($m_cache,'702','b',$name->{namePart}->{given});
+ marc_add($m_cache,'702','4',$role);
} else {
die "FATAL: don't know how to map role '$role'" if ($role);
}
if ($note) {
foreach my $n (split(/\s*;\s+/, $note)) {
if ($n =~ s/bibliogr:\s+//i) {
- marc_arr($m,'320','a',"Bibliografija: $n");
+ marc_add($m_cache,'320','a',"Bibliografija: $n");
} elsif ($n =~ s/ilustr:\s+//i) {
- marc_arr($m,'215','c', $n);
+ marc_add($m_cache,'215','c', $n);
} else {
- marc_arr($m,'320','a',$n);
+ marc_add($m_cache,'320','a',$n);
}
}
}
if ($type) {
if ($type eq "isbn") {
- marc_arr($m,'010','a',$ref->{identifier}->{content});
+ marc_add($m_cache,'010','a',$ref->{identifier}->{content});
} elsif ($type eq "issn") {
- marc_arr($m,'011','a',$ref->{identifier}->{content});
+ marc_add($m_cache,'011','a',$ref->{identifier}->{content});
} else {
die "unknown identifier type $type";
}
if ($tmp->{str}) {
$data .= $tmp->{str}." str";
}
- marc_arr($m,'210','a', $data) if ($data);
- marc_arr($m,'210','d', $tmp->{visina});
+ marc_add($m_cache,'215','a', $data) if ($data);
+ marc_add($m_cache,'215','d', $tmp->{visina});
}
- marc_arr($m,'001','',$ref->{recordInfo}->{recordIdentifier});
+ marc_add($m_cache,'001',undef,$ref->{recordInfo}->{recordIdentifier});
- marc_arr($m,'200','a',$ref->{titleInfo}->{title});
- marc_arr($m,'200','e',$ref->{titleInfo}->{subTitle});
+ marc_add($m_cache,'200','a',$ref->{titleInfo}->{title});
+ marc_add($m_cache,'200','e',$ref->{titleInfo}->{subTitle});
- marc_arr($m,'675','a',$ref->{classification}->{udc});
+ marc_add($m_cache,'675','a',$ref->{classification}->{udc});
my $related = $ref->{relatedItem}->{type};
if ($related) {
if ($related eq "series") {
- marc_arr($m,'675','a',$ref->{relatedItem}->{titleInfo}->{title});
- marc_arr($m,'999','a',$ref->{relatedItem}->{titleInfo}->{partNumber});
+ marc_add($m_cache,'225','a',$ref->{relatedItem}->{titleInfo}->{title});
+ marc_add($m_cache,'999','a',$ref->{relatedItem}->{titleInfo}->{partNumber});
} elsif ($related eq "preceding") {
- marc_arr($m,'430','a',$ref->{relatedItem}->{titleInfo}->{title});
+ marc_add($m_cache,'430','a',$ref->{relatedItem}->{titleInfo}->{title});
} else {
die "can't parse related item type $related" if ($related);
}
}
- marc_arr($m,'205','a',$ref->{originInfo}->{edition});
+ marc_add($m_cache,'205','a',$ref->{originInfo}->{edition});
my $publisher = $ref->{originInfo}->{publisher};
if ($publisher =~ m,^(.+?)\s*/\s*(.+)$,) {
- marc_arr($m,'210','a', $2);
- marc_arr($m,'210','c', $1);
+ marc_add($m_cache,'210','a', $2);
+ marc_add($m_cache,'210','c', $1);
} else {
- marc_arr($m,'210','c', $publisher);
+ marc_add($m_cache,'210','c', $publisher);
}
- marc_arr($m,'326','a',$ref->{originInfo}->{frequency});
- marc_arr($m,'326','a',$ref->{originInfo}->{place});
+ marc_add($m_cache,'326','a',$ref->{originInfo}->{frequency}) if ($journal);
+
+ marc_add($m_cache,'210','a',$ref->{originInfo}->{place});
- marc_arr($m,'210','d',$ref->{originInfo}->{dateIssued});
+ marc_add($m_cache,'210','d',$ref->{originInfo}->{dateIssued});
$nr++;
print "$nr " if ($nr % 100 == 0);
+ # dump record
+ my $m=$marc->createrecord();
+ foreach my $fld (keys %{$m_cache}) {
+# print "$fld: ",join(" * ",@{$m_cache->{$fld}}),"\n";
+ $marc->addfield({record=>$m,
+ field=>$fld,
+ value=>\@{$m_cache->{$fld}}
+ });
+ }
+
$t->purge; # frees the memory
}
-__END__
-
-KNJIGA = {
-610a 'subject' => [
- {
- 'topic' => [
- 'LIBRARIES-AUTOMATION',
- 'ELECTRONIC DATA PROCESSING-LIBRARY SCIENCE'
- ]
- }
- ],
- 'name' => [
- {
- 'namePart' => {
-700b,701a... 'given' => 'Robert M.',
-700a,701b... 'family' => 'Hayes'
- },
- 'type' => 'personal',
- 'role' => {
- 'roleTerm' => {
-7004,7014... 'content' => 'author',
- 'type' => 'text'
- }
- }
- },
- {
- 'namePart' => {
-702b 'given' => 'Joseph',
-702a 'family' => 'Becker'
- },
- 'type' => 'personal',
- 'role' => {
- 'roleTerm' => {
-7024 'content' => 'editor',
- 'type' => 'text'
- }
- }
- },
- {
- 'namePart' => {
-702b 'given' => 'Joseph',
-702a 'family' => 'Becker'
- },
- 'type' => 'personal',
- 'role' => {
- 'roleTerm' => {
-7024 'content' => 'illustrator',
- 'type' => 'text'
- }
- }
- }
- ],
- 'note' => 'bibliogr: 645-647; kazalo; ilustr: ilustr.',
- 'identifier' => {
-010a 'content' => '0-471-36483-5',
- 'type' => 'isbn'
- },
-215a;215d 'physicalDescription' => 'str: 688; pagin: xvi; visina: 24. cm',
-001 'recordInfo' => {
- 'recordIdentifier' => 'k-7996-8073'
- },
-200a 'titleInfo' => {
- 'title' => 'Handbook of data processing for libraries'
- },
- 'typeOfResource' => 'text',
-675a 'classification' => {
- 'udc' => '=20'
- },
-225a 'relatedItem' => {
- 'titleInfo' => {
- 'title' => 'A WILEY-BECKER & HAYES SERIES BOOK'
- },
- 'type' => 'series'
- },
- 'originInfo' => {
- 'issuance' => 'monographic',
-205a 'edition' => '2.',
-210c/210a 'publisher' => 'MELVILLE PUBLISHING COMPANY /LOS ANGELES, CALIFORNIA/',
-210d 'dateIssued' => '1974'
- }
- };
-
-
-
- CASOPIS = {
- 'identifier' => {
-011a 'content' => '1041-5173',
- 'type' => 'issn'
- },
- 'recordInfo' => {
- 'recordIdentifier' => 'c-1'
- },
- 'titleInfo' => {
- 'title' => 'DBMS - CLIENT/SERVER COMPUTING'
- },
- 'typeOfResource' => 'text',
-999a 'relatedItem' => {
- 'titleInfo' => {
- 'partNumber' => 'g. 1990, vol. 137, br. 5'
- },
- 'type' => 'series'
- },
- 'classification' => {
- 'udc' => '=20'
- },
- 'originInfo' => {
-326a 'frequency' => 'mjeseļæ½no',
- 'issuance' => 'continuing',
-210a 'place' => 'SAN MATEO, KANADA',
-210c 'publisher' => 'M&T PUBLISHING INC.'
- }
- };
-
-
-=cut
-