How do I bulk delete bibliographic records (of one given item type)?
Hi everyone... and Happy New Year! :) I thought this would be easy, but I'm not finding it: in Koha 3.0.x (3.0.5, in my case), is there a way to bulk delete biblio records (of one given item type), either using the web interface or some command line tool / script? In case it is relevant, I'm running Koha in SUSE (SLES 11 - SUSE Linux Enterprise Server), and it's an UNIMARC and NoZebra installation. I know that I could run the Perl script "bulkmarcimport.pl" with the "-d" (delete) switch, in the command line, but that would delete EVERY bibliographic record, and that's not what I want. Thanks in advance. Cheers, Ricardo Dias Marques lists AT ricmarques DOT net Installation Guide for Installing Koha 3 on openSUSE 11 http://wiki.koha.org/doku.php?id=opensuse_11.0
Ricardo, there is a new bulk delete tool coming in 3.2 - it's in HEAD right now which is being tested for production. Nicole On Wed, Jan 6, 2010 at 7:14 AM, Ricardo Dias Marques <lists@ricmarques.net> wrote:
Hi everyone... and Happy New Year! :)
I thought this would be easy, but I'm not finding it: in Koha 3.0.x (3.0.5, in my case), is there a way to bulk delete biblio records (of one given item type), either using the web interface or some command line tool / script?
In case it is relevant, I'm running Koha in SUSE (SLES 11 - SUSE Linux Enterprise Server), and it's an UNIMARC and NoZebra installation.
I know that I could run the Perl script "bulkmarcimport.pl" with the "-d" (delete) switch, in the command line, but that would delete EVERY bibliographic record, and that's not what I want.
Thanks in advance.
Cheers, Ricardo Dias Marques lists AT ricmarques DOT net Installation Guide for Installing Koha 3 on openSUSE 11 http://wiki.koha.org/doku.php?id=opensuse_11.0 _______________________________________________ Koha mailing list Koha@lists.katipo.co.nz http://lists.katipo.co.nz/mailman/listinfo/koha
Hi Nicole (and list), On Wed, Jan 6, 2010 at 13:45, Nicole Engard <nengard@gmail.com> wrote:
Ricardo, there is a new bulk delete tool coming in 3.2 - it's in HEAD right now which is being tested for production.
Thank you very much for the feedback. So, I guess that means there's *no* bulk deletion tool for bibliographic records in Koha 3.0.5, right? What's the name of the bulk delete tool (script filename) in the HEAD of the "master" branch? Is it the "batchMod.pl" script that's available in "git.koha.org" in the "tools" directory? Specifically, this one: http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blob;f=tools/batchMod.pl;h=8... Cheers, Ricardo Dias Marques lists AT ricmarques DOT net
I access the tool via the browser with this URL: cgi-bin/koha/tools/batchMod.pl?del=1 So I think that file you pointed to is the right one, but you'd have to ask someone from BibLibre - they're the ones who wrote this awesome new addition (along with a ton of others)! Nicole On Wed, Jan 6, 2010 at 12:33 PM, Ricardo Dias Marques <lists@ricmarques.net> wrote:
Hi Nicole (and list),
On Wed, Jan 6, 2010 at 13:45, Nicole Engard <nengard@gmail.com> wrote:
Ricardo, there is a new bulk delete tool coming in 3.2 - it's in HEAD right now which is being tested for production.
Thank you very much for the feedback. So, I guess that means there's *no* bulk deletion tool for bibliographic records in Koha 3.0.5, right?
What's the name of the bulk delete tool (script filename) in the HEAD of the "master" branch? Is it the "batchMod.pl" script that's available in "git.koha.org" in the "tools" directory? Specifically, this one:
http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blob;f=tools/batchMod.pl;h=8...
Cheers, Ricardo Dias Marques lists AT ricmarques DOT net
Hi again Nicole and list, On Wed, Jan 6, 2010 at 17:40, Nicole Engard <nengard@gmail.com> wrote:
I access the tool via the browser with this URL: cgi-bin/koha/tools/batchMod.pl?del=1
So I think that file you pointed to is the right one, but you'd have to ask someone from BibLibre - they're the ones who wrote this awesome new addition (along with a ton of others)!
Right, thanks. I tried to use this bulk / mass biblio records (and associated items) deletion tool in Koha 3.0.5, by copying some files from the "master" branch to my Koha 3.0.5 directories / folders, namely : 1 - copying "batchMod.pl" - from http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blob;f=tools/batchMod.pl;h=8... - to /koha/koha30xclone/tools 2 - copying "batchMod-del.tmpl" - from http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=tree;f=koha-tmpl/intranet-tm... - to /koha/koha30xclone/koha-tmpl/intranet-tmpl/prog/en/modules/tools 3 - copying "batchMod.tmpl" - from http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blob;f=koha-tmpl/intranet-tm... - also to /koha/koha30xclone/koha-tmpl/intranet-tmpl/prog/en/modules/tools Then, I tried to access the URL http://myhost:8080/cgi-bin/koha/tools/batchMod.pl?del=1 that you suggested and I got a nice web page called "Batch deletion" prompting me for a "Barcodes file", an "Item Id's file" or a "Barcodes list". I thought: this is great! I managed to get the barcodes list that I needed, by running the following MySQL query for my Koha database (I wanted to delete all records that have an Item type of "2") : mysql> select barcode from biblioitems, items where itemtype=2 and biblioitems.biblionumber = items.biblionumber and biblioitems.biblioitemnumber = items.biblioitemnumber; By doing this, I got the list of the barcodes that I needed. I copied and pasted that list to the "Barcodes list" text area of the "Batch deletion" web page. I clicked on the "Continue" button, but received then an error message: ---------------------------------------- Koha error The following fatal error has occurred: Undefined subroutine &main::Item2Marc called at /koha/koha30xclone/tools/batchMod.pl line 389. ---------------------------------------- By doing some research, I see that I would need (at least) to change the "Items.pm" file, in the "C4" Koha 3.0.5 directory, with code that was added in the "master" branch (and that contains that new "Item2Marc" function / subroutine). I wish to avoid that, if possible (because that seems to be touching a more "essential" part of my Koha installation, and I'm afraid that could cause other problems). So, let me rephrase my initial question: how do people *currently* do batch deletions / bulk deletions of bibliographic records (and associated items), for a given / specific item type, in Koha 3.0.x (e.g. 3.0.5)? Thanks again! Cheers, Ricardo Dias Marques lists AT ricmarques DOT net
Ricardo Dias Marques a écrit :
Hi again Nicole and list, mysql> select barcode from biblioitems, items where itemtype=2 and biblioitems.biblionumber = items.biblionumber and biblioitems.biblioitemnumber = items.biblioitemnumber;
that's exactly the best option !
By doing some research, I see that I would need (at least) to change the "Items.pm" file, in the "C4" Koha 3.0.5 directory, with code that was added in the "master" branch (and that contains that new "Item2Marc" function / subroutine). I wish to avoid that, if possible (because that seems to be touching a more "essential" part of my Koha installation, and I'm afraid that could cause other problems).
wise decision. I can guarantee that the "at least" on 1st line would in fact be "first", and have many others after !
So, let me rephrase my initial question: how do people *currently* do batch deletions / bulk deletions of bibliographic records (and associated items), for a given / specific item type, in Koha 3.0.x (e.g. 3.0.5)?
I think they don't, that's why we added this feature. A small Perl script could do the job you want though. Something like : use C4::Context; use C4::Items; use C4::Koha; my $dbh=C4::Context->dbh; my $sth=$dbh->prepare(" select biblio.biblionumber,itemnumber from biblioitems, items where itemtype=2 and biblioitems.biblionumber = items.biblionumber and biblioitems.biblioitemnumber = items.biblioitemnumber; "); $sth->execute while (my ($biblionmber,$itemnumber) = $sth->fetchrow) { DelItem($dbh,$biblionumber,$itemnumber); } WARNING : untested script ! -- Paul POULAIN http://www.biblibre.com Expert en Logiciels Libres pour l'info-doc Tel : (33) 4 91 81 35 08
Hi Paul (and list) On Thu, Jan 7, 2010 , Paul Poulain <paul.poulain@biblibre.com> wrote:
Ricardo Dias Marques a écrit :
mysql> select barcode from biblioitems, items where itemtype=2 and biblioitems.biblionumber = items.biblionumber and biblioitems.biblioitemnumber = items.biblioitemnumber;
that's exactly the best option !
Great. Many thanks for the feedback! :)
By doing some research, I see that I would need (at least) to change the "Items.pm" file, in the "C4" Koha 3.0.5 directory, with code that was added in the "master" branch (and that contains that new "Item2Marc" function / subroutine). I wish to avoid that, if possible (because that seems to be touching a more "essential" part of my Koha installation, and I'm afraid that could cause other problems).
wise decision. I can guarantee that the "at least" on 1st line would in fact be "first", and have many others after !
Right, I though so. Thanks for confirming my impression.
So, let me rephrase my initial question: how do people *currently* do batch deletions / bulk deletions of bibliographic records (and associated items), for a given / specific item type, in Koha 3.0.x (e.g. 3.0.5)?
I think they don't, that's why we added this feature. A small Perl script could do the job you want though. Something like : [ snipped example script. Thank you very much for the script Paul! ]
Cool. Thank you for the Perl script! I ended up writing a similar script and it seemed to do the trick: ---------------------------------------- #!/usr/bin/perl use warnings; use strict; use C4::Context; use C4::Items; use C4::Koha; use C4::Biblio; my $dbh = C4::Context->dbh; my $query2 = "select biblio.biblionumber, biblioitems.biblioitemnumber, items.itemnumber from biblio, biblioitems, items where itemtype=2 and biblio.biblionumber = biblioitems.biblionumber and biblioitems.biblionumber=biblio.biblionumber and biblioitems.biblioitemnumber = items.biblioitemnumber;"; my $sth2 = $dbh->prepare("$query2"); $sth2->execute or die("ERROR: Could not run the query: $query2 The following error occurred: $! \n"); while (my ($biblionumber, $biblioitemnumber, $itemnumber) = $sth2->fetchrow) { print "Deleting item record with biblionumber = $biblionumber and itemnumber = $itemnumber \n"; DelItem($dbh,$biblionumber,$itemnumber); print "Deleting biblio record with biblionumber = $biblionumber \n"; DelBiblio($biblionumber); } ---------------------------------------- I needed to do a small change in "Biblio.pm" for my script to work (without errors). The change I did was around the line 2800 of that file, by "surrounding" the "unless" block that starts with: unless ($result{'__RAW__'}->{$_} =~ /$biblionumber,$title\-(\d);/) { ... with the following "if" block: if (defined($result{'__RAW__'}->{$_}) && $result{'__RAW__'}->{$_} ne "") Like I said, this seemed to do the trick, at least for me. I'm posting this script in the hope this helps others, as well. As always: I'm NOT giving any guarantees, YMMV, do a database backup before trying this, etc... Thanks again Paul! :) Cheers, Ricardo
participants (3)
-
Nicole Engard -
Paul Poulain -
Ricardo Dias Marques