[Koha] [Koha-devel] Retrieving 10-digit ISBNs in a report

Cab Vinton bibliwho at gmail.com
Fri Mar 9 07:36:57 NZDT 2012


Thank you, Nick!

We're hosted by Equinox, so getting that php code in place would take
a bit of extra work for us.

I'm now thinking that we may better off just using a custom field for
this purpose.

If we stick w/ Amazon, their ASIN would be the best way to go. This is
the ISBN for most books, but something else entirely when dealing with
movies & certain other items. Yet another step in our cataloging
workflow ...

Then again, there are other options for book covers, so I'll be
looking into Google Books, LibraryThing, etc. If folks have specific
thoughts on this, I'd be happy to hear them.

Many thanks again,

Cab Vinton, Director
Sanbornton Public Library
Sanbornton, NH

Life is short. Read fast!



On Thu, Mar 8, 2012 at 12:49 AM, Nicholas van Oudtshoorn
<vanoudt at gmail.com> wrote:
> A simple bit of code can be used to get the first valid 10-digit ISBN. This
> is the php code we use - it could be adapted to perl quite easily,
> though.... (Actually, if I recall correctly, there is a C4 function to get
> the Normalised ISBN...)
>
> // Normalise the ISBN
> $isbn = preg_replace('/(.*) \| (.*)/', '$1', $isbn); // Get first isbn
> $isbn = preg_replace('/(.*) (.*)/', '$1', $isbn); // Get rid of text
> if (strlen($isbn) == 11) {
>  if ($debugging) { print "Chopping 11 digit ISBN to a 10 digit ISBN"; }
>  $isbn = substr($isbn,1,10);
> } else if (strlen($isbn) == 13) {
>  $isbn = substr($isbn,3,9);
>  $checksum = 0;
>  $weight = 10;
>  $isbnCharArray = str_split($isbn);
>  foreach($isbnCharArray as $char) {
>    $checksum += $char * $weight;
>    $weight--;
>  }
>  $checksum = 11-($checksum % 11);
>  if ($checksum == 10) {
>    $isbn += "X";
>  } else if ($checksum == 11) {
>    $isbn += "0";
>  } else {
>    $isbn .= $checksum;
>  }
> } else if (strlen($isbn) != 10) {
>  if ($debugging) { print "<p>Illegal ISBN Found: $isbn</p>"; }
>    exit;
> }
> if ($debugging) { print "Normalised ISBN: $isbn"; exit; }
>
>
> -
> Nick
>
>
> On 03/07/2012 05:50 AM, Cab Vinton wrote:
>>
>> Hi, All --
>>
>> For the purposes of creating a web-based carousel of book covers of
>> our recent acquisitions, I'd like to run a report that generates a
>> list of ISBNs of items added between 2 dates.
>>
>> Amazon&  therefore Koha rely on 10-digit ISBNs for book cover retrieval.
>>
>>
>> However, when I run a report using biblioitems.isbn, this is the
>> output I get. Many truncated ISBNs, presumably because the max length
>> = 30 restriction.
>>
>> 9780425243244 (pbk.) | 0425243
>> 9780307718099 | 0307718093
>> 0804840288 | 9780804840286 (tr
>> 9780811876377 : | 0811876373 :
>> 1569244677
>> 9781400064588 (acidfree paper)
>> 9780061429255 | 0061429252
>> 9781451661064 (hardcover) | 14
>>
>> Is there a way to run a report that outputs only the 10 digit ISBNs?
>>
>> Many thanks,
>>
>> Cab Vinton, Director
>> Sanbornton Public Library
>> Sanbornton, NH
>> _______________________________________________
>> Koha-devel mailing list
>> Koha-devel at lists.koha-community.org
>> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
>> website : http://www.koha-community.org/
>> git : http://git.koha-community.org/
>> bugs : http://bugs.koha-community.org/
>>
>
>
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.koha-community.org
> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : http://www.koha-community.org/
> git : http://git.koha-community.org/
> bugs : http://bugs.koha-community.org/


More information about the Koha mailing list