From 4e9dd57082a67bcd1c923fd22611e4e312625d7d Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 7 Apr 2005 11:56:05 +0000 Subject: [PATCH] script to rebuild COUNTRY authorised values list (like builLANG for langs) --- misc/migration_tools/buildCOUNTRY.pl | 97 ++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 misc/migration_tools/buildCOUNTRY.pl diff --git a/misc/migration_tools/buildCOUNTRY.pl b/misc/migration_tools/buildCOUNTRY.pl new file mode 100755 index 0000000000..d9699ef145 --- /dev/null +++ b/misc/migration_tools/buildCOUNTRY.pl @@ -0,0 +1,97 @@ +#!/usr/bin/perl +# script that rebuild thesaurus from biblio table. + +# delete FROM `marc_subfield_table` WHERE tag = "606" AND subfieldcode = 9; +use strict; + +# Koha modules used +# use MARC::File::USMARC; +# use MARC::Record; +# use MARC::Batch; +use C4::Context; +use C4::Biblio; +use C4::AuthoritiesMarc; +use Time::HiRes qw(gettimeofday); + +use Getopt::Long; +my ( $fields, $number,$language) = ('',0); +my ($version, $verbose, $test_parameter, $field,$delete,$subfields); +GetOptions( + 'h' => \$version, + 'd' => \$delete, + 't' => \$test_parameter, + 's:s' => \$fields, + 'v' => \$verbose, + 'l:s' => \$language, +); + +if ($version or !$fields) { + print < 'english', + 'fre' => 'french' + ); + +%codesiso = ( + 'an' => 'Antilles Néerlandaises', + 'at' => 'Autriche', + 'cr' => 'Costa Rica', + 'er' => 'Erythrée', + 'fr' => ' France', + 'in' => 'Inde', + 'is' => 'Islande', + 'lt' => 'Lituanie', + 'nd' => 'Pays Bas', + 'nf' => 'Norfolk', + 'ng' => 'Nigéria', + 'pa' => 'Manama', + 'pn' => 'Pitcairn', + 're' => 'Réunion (ile)', + 'sp' => 'Espagne', + 'us' => 'Etats Unis', + ) if $language eq 'fr'; + +my $dbh = C4::Context->dbh; +if ($delete) { + print "deleting country list\n"; + $dbh->do("delete from authorised_values where category='COUNTRY'"); +} + +if ($test_parameter) { + print "TESTING MODE ONLY\n DOING NOTHING\n===============\n"; +} +my $starttime = gettimeofday; + +my $sth = $dbh->prepare("SELECT count(*) as tot,subfieldvalue FROM marc_subfield_table WHERE tag + subfieldcode IN $fields group by subfieldvalue"); + +$sth->execute; +my $i=1; + +print "=========================\n"; +my $sth2 = $dbh->prepare("insert into authorised_values (category, authorised_value, lib) values (?,?,?)"); +while (my ($tot,$langue) = $sth->fetchrow) { + $sth2->execute('COUNTRY',$langue,$langue?$codesiso{$langue}:$langue); + print "$langue is unknown is iso list (used $tot times)\n" unless $codesiso{$langue}; +} +print "=========================\n"; -- 2.39.5