19 |
use File::Path; |
use File::Path; |
20 |
use Time::HiRes qw/time/; |
use Time::HiRes qw/time/; |
21 |
use File::Slurp; |
use File::Slurp; |
22 |
|
use MARC::Record 2.0; # need 2.0 for utf-8 encoding see marcpm.sf.net |
23 |
|
|
24 |
=head1 NAME |
=head1 NAME |
25 |
|
|
235 |
|
|
236 |
$log->info("Using $normalize_path for normalization..."); |
$log->info("Using $normalize_path for normalization..."); |
237 |
|
|
238 |
|
my $marc_fh; |
239 |
|
if (my $path = $normalize->{marc21}) { |
240 |
|
open($marc_fh, '>', $path) || |
241 |
|
$log->logdie("can't open MARC output $path: $!"); |
242 |
|
|
243 |
|
$log->info("Creating MARC export file $path\n"); |
244 |
|
} |
245 |
|
|
246 |
# reset position in database |
# reset position in database |
247 |
$input_db->seek(1); |
$input_db->seek(1); |
248 |
|
|
269 |
row => $row, |
row => $row, |
270 |
rules => $rules, |
rules => $rules, |
271 |
lookup => $lookup ? $lookup->lookup_hash : undef, |
lookup => $lookup ? $lookup->lookup_hash : undef, |
272 |
|
marc_encoding => 'utf-8', |
273 |
); |
); |
274 |
|
|
275 |
$db->save_ds( |
$db->save_ds( |
282 |
id => $input->{name} . "/" . $mfn, |
id => $input->{name} . "/" . $mfn, |
283 |
ds => $ds, |
ds => $ds, |
284 |
type => $config->{$use_indexer}->{type}, |
type => $config->{$use_indexer}->{type}, |
285 |
) if ($indexer); |
) if ($indexer && $ds); |
286 |
|
|
287 |
|
if ($marc_fh) { |
288 |
|
my $marc = new MARC::Record; |
289 |
|
$marc->encoding( 'utf-8' ); |
290 |
|
$marc->add_fields( WebPAC::Normalize::_get_marc21_fields() ); |
291 |
|
print $marc_fh $marc->as_usmarc; |
292 |
|
} |
293 |
|
|
294 |
$total_rows++; |
$total_rows++; |
295 |
} |
} |
296 |
|
|
297 |
$log->info("statistics of fields usage:\n", $input_db->stats) if ($stats); |
$log->info("statistics of fields usage:\n", $input_db->stats) if ($stats); |
298 |
|
|
299 |
}; |
# close MARC file |
300 |
|
close($marc_fh) if ($marc_fh); |
301 |
|
|
302 |
|
} |
303 |
|
|
304 |
} |
} |
305 |
|
|