| Revision 678 (by dpavlin, 2005/02/27 23:07:35) |
Experimental support for dBase .dbf files. Usege like this in all2xml.conf:
[hda]
dbf_file=/data/drustvene/hda/ISO.DBF
type=dbf
dbf_codepage=cp852
dbf_mapping=<<_END_OF_MAP_
ID_BROJ 001
ISBN_BROJ 010
SKUPINA1 200
SKUPINA2 205
SKUPINA4 210
SKUPINA5 215
SKUPINA6 225
SKUPINA7 300
ANOTACIJA 330
PREDMET1 610
PREDMET2 610
PREDMET3 510
UDK 675
REDALICA 700
SIGNATURA 990
_END_OF_MAP_
dbf type will use <isis> tag in import_xml and dbf_codepage will
override codepage specified in import_xml file.
Small code refactoring.
|
# This is slight modification of to_hash as included in Biblio::Isis
#
# This is incredibly bad (duplicate code), but it would have to wait for
# WebPac v2 to be fixed by extracting all file imported in sane OO way.
sub to_hash {
my $mfn = shift || confess "need mfn!";
my $row = shift || confess "need data";
# init record to include MFN as field 000
my $rec = { '000' => [ $mfn ] };
foreach my $k (keys %{$row}) {
foreach my $l (@{$row->{$k}}) {
my $val;
# has identifiers?
#($val->{'i1'},$val->{'i2'}) = ($1,$2) if ($l =~ s/^([01 #])([01 #])\^/\^/);
# has subfields?
if ($l =~ m/[\^\$]/) {
foreach my $t (split(/[\^\$]/,$l)) {
next if (! $t);
$val->{substr($t,0,1)} = substr($t,1);
}
} else {
$val = $l;
}
push @{$rec->{$k}}, $val;
}
}
return $rec;
}
1;