Reputation: 9927
I've got ISBN numbers (10-digits and 13 digits) without the dashes. Now I'm looking for a way to add those dashes automatically.
I found some useful information here: http://www.isbn.org/standards/home/isbn/international/hyphenation-instructions.asp
But I'm not sure if it's doable at all, because the publisher identifier has a random length, and without knowing it, it's maybe not possible to determine the correct positions for the dashes.
Does anybody know if it's possible somehow?
Thanks a lot!
Upvotes: 23
Views: 11902
Reputation: 1
First, download the full ranges file from International ISBN Agency. This file will include Registration Groups. Each group has Rules for each publisher range. The ranges are seven digit numbers. The file also always contains the ISBN-13 prefix, so if you are trying to hyphenate an ISBN-10, just add 978 before it and you should be able to find which group to use.
Next, you will need to take the next 7 digits after the first 4 for ISBN-13 or the next 7 digits after the first digit for ISBN-10. Wherever that number falls in the publisher ranges tells you how many digits of the 7 are actually the publisher code. The last digit is the check digit. It can be 0-9 or X (which stands for 10). The rest of the digits are the book code.
One more thing. Even though ISBN-10 and ISBN-13 have the same publisher code and book code so that they look similar, they will not have the same check digit. You can translate an ISBN-10 to ISBN-13 but you will need to use the right algorithm to determine the check digit for ISBN-13. Find that here.
Upvotes: 0
Reputation: 65854
You can deduce the length of the publisher identifier if you have the full range tables.
Example 1. ISBN 0141439564 (Penguin: Great Expectations)
Example 2. ISBN 2253004227 (Poche: Germinal)
You can check your algorithm at the Library of Congress's ISBN hyphenation tool.
Upvotes: 21
Reputation: 366
Take a look at https://pypi.python.org/pypi/isbntools, it will allow you to 'hyphenate' ISBNs and much more, like extracting, cleanning, transforming, and get metadata.
This is a library (that you can use in your program) but it installs several 'scripts' that you can use from the command line.
Upvotes: 1
Reputation: 301
I wrote the following JavaScript function to hyphenate ISBNs (I know there is also isbnjs, but this is more compact and easier to include in other projects I think).
https://gist.github.com/aurimasv/6693537
Upvotes: 1
Reputation: 5078
For Python, you can use the library python-stdnum, isbnid or isbn_hyphenate. They can hyphenate ISBNs, and use the range table mentioned in the other answer.
Upvotes: 5