From b3605e283a79f810d93898e043abe699d0588d68 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 11 Sep 2013 17:39:19 +0200 Subject: [PATCH] first cut at parsing crolist csv files --- crolist2marc.pl | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 crolist2marc.pl diff --git a/crolist2marc.pl b/crolist2marc.pl new file mode 100755 index 0000000..a233047 --- /dev/null +++ b/crolist2marc.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl +use warnings; +use strict; +use autodie; + +use MARC::Record; +use Data::Dump qw(dump); + +my $data; + +my $lines = 0; + +open(my $fh, '<', 'TEKTAG.csv'); +my $h = <$fh>; # header +while(<$fh>) { + chomp; + my ( $idsl, $tag, $tagno, $id, $sfi, $sfino, $textkey, $textres ) = split(/,/,$_); + + $tagno ||= 0; + $sfino ||= 0; + + $id .= " " if length $id < 2; + $id .= " " if length $id < 2; + my ($i1, $i2) = split(//, $id, 2); + + $sfi =~ s/^\$// || die "can't fix subfield [$sfi]"; + + $data->{$idsl}->{$tag}->[ $tagno ]->[ 0 ] = $i1; + $data->{$idsl}->{$tag}->[ $tagno ]->[ 1 ] = $i2; + $data->{$idsl}->{$tag}->[ $tagno ]->[ ( $sfino * 2 ) + 2 ] = $sfi; + $data->{$idsl}->{$tag}->[ $tagno ]->[ ( $sfino * 2 ) + 3 ] = $textkey . $textres; + +# last if $lines++ > 5000; +} + +warn dump($data); + -- 2.20.1