eprints-dev: /home/dpavlin/eprints-ffzg-rebuild.sh [commit]
[eprints3-migration.git] / tsv2xp-xml.pl
index ccae475..3b55f59 100755 (executable)
@@ -69,10 +69,22 @@ while(<$tsv>) {
                $file .= $1 if $full_path =~ m/(\.\w+)$/;
        }
 
+       my $subject;
+       if ( $file =~ m/(\w+)/ ) {
+               $_ = $1;
+               $subject =
+                       m/bib/i    ? 'IZBIB' :
+                       m/in[fo]/i ? 'IZDHI' :
+                       m/muz/i    ? 'IZMUZ' :
+                       m/arh/i    ? 'IZARH' :
+                       die "unknown subject: $2";
+       }
+
        my $c = $col;
        $header2col->{'eprintsid'} = $c; $v[$c++] = $eprintsid++;
        $header2col->{'file'} = $c; $v[$c++] = $file;
        $header2col->{'full_path'} = $c; $v[$c++] = $full_path;
+       $header2col->{'subject'} = $c; $v[$c++] = $subject;
 
        my $eprints = $xml;
        while ( $eprints =~ s/<!-- "(.+?)" -->/interpolate($1)/seg ) {
@@ -80,6 +92,7 @@ while(<$tsv>) {
        }
 
        $eprints =~ s{<documents>.+</documents>}{<!-- no documents -->}s if ! $full_path;
+       $eprints =~ s{<subjects>.+</subjects>}{<!-- no subjects -->}s if ! $subject;
 
        print $eprints;
 }