hello,
Just 2 notes about your attached content:
* please don't do that on mailing list: it's unsolicited content.
provide download urls instead.
* those are not marc files so the exemples given below don't work as
long as you haven't translated it to iso2709.
On Sun, Jan 20, 2013 at 03:54:18PM +0100, samuel desseaux wrote:
> Hi,
>
> I work on files for our library and i need some help.
>
> I have one file with all biblio records and one with items. A biblio record
> can have one or more than one item.
>
> First operation: i want to compare the two files and the identifier is the
> field 001. I want to have th results in two separates files
>
> 1st: all the items which have the same 001 field like in the biblio record
>
> 2nd: all the items which have not the same 001 field like in the biblio
> record
not tested but here is a good base:
use Modern::Perl;
use autodie;
use MARC::MIR;
my %biblio;
my %report;
map { open $report{$_},">$_.matches.txt" } qw< do dont >;
marawk { $biblio{(record_id)}=1 } 'biblio.mrc';
marawk {
my $id = record_id;
my $as = $biblio_id{ $to } ? 'do' : 'dont';
say $report{$as}, $id;
} 'items.mrc';
> Second operation: In my item files, all items of a same biblio record have
> the same 001 field but they are all separated. I'd like to join all the
> items under only one 001 field
a) be carefull: it will load the whole file in memory
b) not tested :)
use Modern::Perl;
use autodie;
use MARC::MIR;
my %items_for;
marawk { push @ { $items_for{(record_id)} } , $_ } 'items.mrc';
open my $fh,'>sorted.items.mrc';
map { map {print $fh to_iso2709} @$_ } values %items_for;
> After, with the new file, i want to merge with biblio record and if i find
> 2 identical 001, i attached the items on the biblio record
i don't get it. you want to merge item records and biblio record?
> Third operation: how can i correct some data bad encoded. It's due to the
> old database which doesn't respect UTF8.
i see no problem in the provided content.
regards
marc