package cmftf; ## Create MARC From Text File ## Copyright 2004 Baiju M ## This program is licensed under GNU GPL. use strict; use MARC::Record; my $input_file = "/root/fctveout.txt"; my $output_file = "/root/fctvef.out"; my $repeated_items = " "; open(INFILE, $input_file) or die "Can't open $input_file: $!"; open(OUTFILE, ">>", $output_file) or die "Can't open $output_file: $!"; my $c = 0; while () { $c++; my $biblionumber_ftf_691_090_c, my $title_ftf_4_245_a, my $edition_ftf_7_250_a, my $publisher_ftf_11_260_b, my $publishcountry_ftf_12_260_a, my $publishyear_ftf_13_260_c, my $author1ee_ftf_18_100_a, my $author1se_ftf_19_100_a, my $author2ee_ftf_20_700_a, my $author2se_ftf_21_700_a, my $adiauthors_ftf_24_700_a, my $itemtype_ftf_25_942_c, my $role_ftf_38_590_a, my $phydescr_ftf_10_300_a, my $classno_ftf_114_852_k, my $classno_ftf_115_852_h, my $keyword_ftf_5_520_a, my $voldetails_ftf_110_440_v, my $dateofentry_ftf_122_952_v, my $notes_ftf_97_500_a, my $isbn_ftf_60_020_a, my $subject_ftf_70_650_a, my $recordedby_ftf_80_946_a, my $pubprice_151_952_r, my $currency_153_590_b, my $reccreated_123_508_a, my $remainder; ($biblionumber_ftf_691_090_c, $title_ftf_4_245_a, $edition_ftf_7_250_a, $publisher_ftf_11_260_b, $publishcountry_ftf_12_260_a, $publishyear_ftf_13_260_c, $author1ee_ftf_18_100_a, $author1se_ftf_19_100_a, $author2ee_ftf_20_700_a, $itemtype_ftf_25_942_c, $author2se_ftf_21_700_a, $adiauthors_ftf_24_700_a, $role_ftf_38_590_a, $phydescr_ftf_10_300_a, $classno_ftf_114_852_k, $classno_ftf_115_852_h, $keyword_ftf_5_520_a, $voldetails_ftf_110_440_v, $dateofentry_ftf_122_952_v, $notes_ftf_97_500_a,$isbn_ftf_60_020_a, $subject_ftf_70_650_a, $recordedby_ftf_80_946_a, $pubprice_151_952_r, $currency_153_590_b, $reccreated_123_508_a, $remainder) = split(/\t/, $_, 23); if (($biblionumber_ftf_691_090_c !~ /[^\d]/) and ($title_ftf_4_245_a !~ /_B_L_A_N_K_/) and ($repeated_items !~ /$biblionumber_ftf_691_090_c/) ) { $repeated_items .= " $biblionumber_ftf_691_090_c"; my @biblionumber_array; open(INF, $input_file) or die "Can't open $input_file: $!"; my $i = 1; while () { $i++; if ($i >= $c) { my $biblionumber_ftf_691_090_c2, my $title_ftf_4_245_a2, my $edition_ftf_7_250_a2, my $publisher_ftf_11_260_b2, my $publishcountry_ftf_12_260_a2, my $publishyear_ftf_13_260_c2, my $author1ee_ftf_18_100_a2, my $author1se_ftf_19_100_a2, my $author2ee_ftf_20_700_a2, my $author2se_ftf_21_700_a2, my $adiauthors_ftf_24_700_a2, my $itemtype_ftf_25_942_c2, my $role_ftf_38_590_a2, my $phydescr_ftf_10_300_a2, my $classno_ftf_114_852_k2, my $classno_ftf_115_852_h2, my $keyword_ftf_5_520_a2, my $voldetails_ftf_110_440_v2, my $dateofentry_ftf_122_952_v2, my $notes_ftf_97_500_a2, my $isbn_ftf_60_020_a2, my $subject_ftf_70_650_a2, my $recordedby_ftf_80_946_a2, my $pubprice_151_952_r2, my $currency_153_590_b2, my $reccreated_123_508_a2, my $remainder2; ($biblionumber_ftf_691_090_c2, $title_ftf_4_245_a2, $edition_ftf_7_250_a2, $publisher_ftf_11_260_b2, $publishcountry_ftf_12_260_a2, $publishyear_ftf_13_260_c2, $author1ee_ftf_18_100_a2, $author1se_ftf_19_100_a2, $author2ee_ftf_20_700_a2, $author2se_ftf_21_700_a2, $adiauthors_ftf_24_700_a2, $itemtype_ftf_25_942_c2, $role_ftf_38_590_a2, $phydescr_ftf_10_300_a2, $classno_ftf_114_852_k2, $classno_ftf_115_852_h2, $keyword_ftf_5_520_a2, $voldetails_ftf_110_440_v2, $dateofentry_ftf_122_952_v2, $notes_ftf_97_500_a2, $isbn_ftf_60_020_a2, $subject_ftf_70_650_a2, $recordedby_ftf_80_946_a2, $pubprice_151_952_r2, $currency_153_590_b2, $reccreated_123_508_a2, $remainder2) = split(/\t/, $_, 23); if (($biblionumber_ftf_691_090_c2 !~ /[^\d]/) and ($title_ftf_4_245_a2 !~ /_B_L_A_N_K_/) and ($title_ftf_4_245_a2 eq $title_ftf_4_245_a) and ($author1ee_ftf_18_100_a2 eq $author1ee_ftf_18_100_a)){ print "$biblionumber_ftf_691_090_c:$biblionumber_ftf_691_090_c2\t"; $repeated_items .= " $biblionumber_ftf_691_090_c2"; push @biblionumber_array, $biblionumber_ftf_691_090_c2; } } } print "\n"; close(INF); my $record = MARC::Record->new(); if ($isbn_ftf_60_020_a !~ /_B_L_A_N_K_/) { my $isbn = MARC::Field->new( '020','','', a => $isbn_ftf_60_020_a ); $record->add_fields($isbn); } if ($author1ee_ftf_18_100_a =~ /_B_L_A_N_K_/) { $author1ee_ftf_18_100_a = ""; } if ($author1se_ftf_19_100_a =~ /_B_L_A_N_K_/) { $author1se_ftf_19_100_a = ""; } my $author1_ftf = join(" ", $author1se_ftf_19_100_a, $author1ee_ftf_18_100_a); if ($author1_ftf ne "") { my $author1 = MARC::Field->new( '100','1','', a => $author1_ftf ); $record->add_fields($author1); } if ($title_ftf_4_245_a !~ /_B_L_A_N_K_/) { my $title = MARC::Field->new( '245','1','2', a => $title_ftf_4_245_a ); $record->add_fields($title); } if ($edition_ftf_7_250_a !~ /_B_L_A_N_K_/) { my $edition = MARC::Field->new( '250','','', a => $edition_ftf_7_250_a ); $record->add_fields($edition); } if ($publishcountry_ftf_12_260_a !~ /_B_L_A_N_K_/) { my $publishcountry = MARC::Field->new( '260','','', a => $publishcountry_ftf_12_260_a ); $record->add_fields($publishcountry); } if ($publisher_ftf_11_260_b =~ /_B_L_A_N_K_/) { $publisher_ftf_11_260_b = ""; } if ($publishyear_ftf_13_260_c =~ /_B_L_A_N_K_/) { $publishyear_ftf_13_260_c = ""; } my $publisher = MARC::Field->new( '260','','', b => $publisher_ftf_11_260_b, c => $publishyear_ftf_13_260_c ); $record->add_fields($publisher); if ($phydescr_ftf_10_300_a =~ /_B_L_A_N_K_/) { $phydescr_ftf_10_300_a = ""; } my $phydescr = MARC::Field->new( '300','','', a => $phydescr_ftf_10_300_a, f => $itemtype_ftf_25_942_c ); $record->append_fields($phydescr); if ($voldetails_ftf_110_440_v !~ /_B_L_A_N_K_/) { my $voldetails = MARC::Field->new( '440','','3', v => $voldetails_ftf_110_440_v ); $record->add_fields($voldetails); } if ($notes_ftf_97_500_a !~ /_B_L_A_N_K_/) { my $notes = MARC::Field->new( '500','','', a => $notes_ftf_97_500_a ); $record->add_fields($notes); } if ($reccreated_123_508_a !~ /_B_L_A_N_K_/) { my $reccreated = MARC::Field->new( '508','','', a => $reccreated_123_508_a ); $record->add_fields($reccreated); } if ($keyword_ftf_5_520_a !~ /_B_L_A_N_K_/) { my $keyword = MARC::Field->new( '520','','', a => $keyword_ftf_5_520_a ); $record->add_fields($keyword); } if ($role_ftf_38_590_a =~ /_B_L_A_N_K_/) { $role_ftf_38_590_a = ''; } if ($currency_153_590_b =~ /_B_L_A_N_K_/) { $currency_153_590_b = ''; } my $role = MARC::Field->new( '590','','', a => $role_ftf_38_590_a, b => $currency_153_590_b ); $record->add_fields($role); if ($subject_ftf_70_650_a !~ /_B_L_A_N_K_/) { my $subject = MARC::Field->new( '650','1','2', a => $subject_ftf_70_650_a ); $record->add_fields($subject); } if ($author2ee_ftf_20_700_a =~ /_B_L_A_N_K_/) { $author2ee_ftf_20_700_a = ""; } if ($author2se_ftf_21_700_a =~ /_B_L_A_N_K_/) { $author2se_ftf_21_700_a = ""; } if ($adiauthors_ftf_24_700_a =~ /_B_L_A_N_K_/) { $adiauthors_ftf_24_700_a = ""; } my $adiauthors_ftf = join(" ", $author2se_ftf_21_700_a, $author2ee_ftf_20_700_a, $adiauthors_ftf_24_700_a); if ($adiauthors_ftf ne "") { my $adiauthors = MARC::Field->new( '700','1','', a => $adiauthors_ftf ); $record->add_fields($adiauthors); } if ($classno_ftf_114_852_k =~ /_B_L_A_N_K_/) { if ($classno_ftf_115_852_h =~ /_B_L_A_N_K_/) { my $classno = MARC::Field->new( '852','','', k => '999.9999' ); $record->add_fields($classno); } else { if ($classno_ftf_115_852_h =~ /^\d\d\d/) { my $classno = MARC::Field->new( '852','','', k => $classno_ftf_115_852_h ); $record->add_fields($classno); } else { my $classno = MARC::Field->new( '852','','', k => '999.9998', h => $classno_ftf_115_852_h ); $record->add_fields($classno); } } } else { if ($classno_ftf_114_852_k =~ /^\d\d\d/) { if ($classno_ftf_115_852_h =~ /_B_L_A_N_K_/) { $classno_ftf_115_852_h = ""; } my $classno = MARC::Field->new( '852','','', k => $classno_ftf_114_852_k, h => $classno_ftf_115_852_h ); $record->add_fields($classno); } else { if ($classno_ftf_115_852_h =~ /^\d\d\d/) { my $classno = MARC::Field->new( '852','','', k => $classno_ftf_115_852_h, h => $classno_ftf_114_852_k ); $record->add_fields($classno); } else { if ($classno_ftf_115_852_h =~ /_B_L_A_N_K_/) { $classno_ftf_115_852_h = ""; } my $classno = MARC::Field->new( '852','','', k => '999.9997', h => $classno_ftf_115_852_h ); $record->add_fields($classno); } } } if ($itemtype_ftf_25_942_c !~ /_B_L_A_N_K_/) { my $itemtype = MARC::Field->new( '942','','', c => $itemtype_ftf_25_942_c ); $record->add_fields($itemtype); } if ($recordedby_ftf_80_946_a !~ /_B_L_A_N_K_/) { my $recordedby = MARC::Field->new( '946','1','', c => $recordedby_ftf_80_946_a ); $record->add_fields($recordedby); } if ($pubprice_151_952_r =~ /_B_L_A_N_K_/) { $pubprice_151_952_r = ''; } if ($dateofentry_ftf_122_952_v =~ /_B_L_A_N_K_/) { $dateofentry_ftf_122_952_v = ''; } my @biblionumber_array_tmp = sort @biblionumber_array; foreach (@biblionumber_array_tmp) { my $biblionumber = $_; my $barcode = MARC::Field->new( '952','','', b => "MAIN", d => "MAIN", p => $biblionumber, r => $pubprice_151_952_r, u => $biblionumber, v => $dateofentry_ftf_122_952_v ); $record->add_fields($barcode); } #print "\n"; print OUTFILE $record->as_usmarc(); } else { #print $_; } } close(OUTFILE);