CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Perl Script to fetch values from Search API

 



pjanakir
New User

Mar 13, 2010, 6:48 PM

Post #1 of 4 (2368 views)
Perl Script to fetch values from Search API Can't Post

I have a large text file delimited with a | symbol consisting of 3 field columns : ISBN (or Barcode number), Catalog Key and OCLC Number in the format -
Barcode | Catalog Key | OCLC #

The Catalog Key can be ignored and if there's no catalog key for a specific barcode, that means there is no OCLC# for that record.

Using the WorldCat API (URL : http://www.worldcat.org/affiliate/tools?atype=wcapi ) and WorldCat Search API URL : http://worldcat.org/devnet/wiki/SearchAPIDetails ), we need to write a script to fetch information for each of the library items identified in the attached text file.

These barcodes would be used to look up the corresponding OCLC number of the publication that the barcode represents. This OCLC number would then be used to interrogate Worldcat to determine the number of different libraries that have the publication.

The output would be the number of libraries in Canada, US and RoW (Rest of the World) that have the publication - as 3 separate numbers - in a tab or pipe delimited file with columns for

Barcode
# Canada (library count in Canada)
# USA (library count in USA)
# RoW (library count in the Rest of the World)
Publication year

If it's hard to get the three geographical counts, then just give me one number for all locations worldwide, that is:

Barcode
#
Publication year

If it's hard to get the publication year, then that can be left out too but getting it from OCLC would help as a confirmation of Quest data accuracy.

I don't need a list of libraries that have each publication, just the number of libraries. If Quest doesn't have an OCLC number, then the output should be the barcode with the other fields as null (empty), not zeroes. What I want is a CSV data file that I can use to manipulate with Excel along with the Perl script.


7stud
Enthusiast

Mar 13, 2010, 9:48 PM

Post #2 of 4 (2363 views)
Re: [pjanakir] Perl Script to fetch values from Search API [In reply to] Can't Post

I should have the program written by the end of the week.


(This post was edited by 7stud on Mar 13, 2010, 9:50 PM)


pjanakir
New User

Mar 15, 2010, 12:55 PM

Post #3 of 4 (2340 views)
Re: [7stud] Perl Script to fetch values from Search API [In reply to] Can't Post

Hello 7stud,

Iam a newbie to both perl and php. From the information given however, I have developed a PHP script. Please take a look and suggest me if I need to tweak my code further to get the desired results as per the given requirements. Iam trying to get an array sum of my library locations which would give me the total library count as specified in the problem (I have not done individual country wise) and also extracting the publication year from the publication date by using strtotime and date functions. Attached please find my code. If you can suggest in Perl, that also would be fine. Just need a script which can do this, it does'nt matter which language it is written in. Should give you a fair idea of the process. Let me know then.

Thanks,
Prab
Attachments: worldcat_holdings_count.php (3.28 KB)


pjanakir
New User

Mar 16, 2010, 3:53 AM

Post #4 of 4 (2327 views)
Re: [7stud] Perl Script to fetch values from Search API [In reply to] Can't Post

7stud,

That approach that I used will be helpful for single-item lookups, but there are too many records in the file to process individually. You may want to look into command-line PHP scripting to handle the OCLC data in batch:

http://www.php.net/manual/en/features.commandline.php

You don't have to use PHP, either, if there are languages you're more comfortable using -- Perl, Python, Java, shell script; it's up to you.

Also, you likely don't need the 'startLibrary', 'maximumLibraries', or 'libType' parameters in your requests: these are to limit the number of libraries from which you retrieve results, and we want to include all libraries within the specified location.

Finally, examine the data returned from a sample API request:

http://www.worldcat.org/webservices/catalog/content/libraries/58599?location=ca&startLibrary=&maximumLibraries=libtype=&wskey=[Worldcat API key from script]

It's possible to fetch results as MARC XML, but using the the above will return XML that conforms to the ISO 20775 Holdings schema, which is simpler to parse.

Please let me know. Iam needing your help very much on this.

Thanks ...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives