Hi Paul,

yes, it's exactly  the way i try to follow.

I've my algorithm but it's a bit hard, (for the moment but i hope to have
more time to learn perl) to write a good code.


samuel


2013/1/21 Paul Hoffman <nkui...@nkuitse.com>

> On Sun, Jan 20, 2013 at 06:43:38PM +0100, samuel desseaux wrote:
> > *the goal is to join properly items with biblio records.
>
> Let's assume that you have these two files:
>
> (B) Three MARC bibliographic records
>
>     1. 001 = 1029
>     2. 001 = 3884
>     3. 001 = 1650
>     (etc.)
>
> (I) Seven MARC item records
>
>     1. 001 = 1029
>     2. 001 = 1650
>     3. 001 = 1029
>     4. 001 = 3884
>     5. 001 = 3884
>     6. 001 = 1650
>     7. 001 = 1650
>
> Do you want to produce a *new* file of three records, like this?
>
>     1. I1 + I3
>     2. I4 + I5
>     3. I2 + I6 + I7
>
> Is this really what you want to have in the end?
>
> > As we have to separate files, it's a bit hard. With MarcEdit, if i
> > merge these two files, it's limited: marcedit doesn't understand that
> > one biblio record can have more than one item :-).  I won't say any
> > more about my library and his exotical old ils i've moved for koha.
>
> It sounds as though what you *really* want in the end is a *single* file
> of three MARC records, like this:
>
>     B1 + I1 + I3
>     B2 + I4 + I5
>     B3 + I2 + I6 + I7
>
> Is that right?  Here's a rough start in Perl:
>
>
> -------->8-------->8-------->8-------->8-------->8-------->8-------->8--------
> use MARC::File;
> my ($file, %records);
> $file = MARC::File::USMARC->in($bib_records_file);
> while (my $bib_marc = read_next_record_from($file) {
>     my $sysnum = sysnum($bib_marc);
>     $records{$sysnum} = [ $bib_marc ];
> }
> $file->close;
> $file = MARC::File::USMARC->in($bib_records_file);
> while (my $item_marc = read_next_record_from($file) {
>     my $sysnum = sysnum($item_marc);
>     push @{ $records{$sysnum} }, $item_marc;
> }
> $file->close;
> print @$_ for values %records;
>
> -------->8-------->8-------->8-------->8-------->8-------->8-------->8--------
>
> Let us know if you need help writing read_next_record_from() or
> sysnum().
>
> Paul.
>
> --
> Paul Hoffman <nkui...@nkuitse.com>
>

Reply via email to