You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been successful in running an OCLC API via python to generate a list of ISSN’s associated with a list of inputted ISSNs.
This has been very useful, and replaces a tool that used to be available through SFX.
I was able to do this be taking the data in a .csv format, and manipulating that data by appending it to Python lists, all of which is close to what I would have done with PHP arrays.
But I GOT CURIOUS over another format the OCLC offers called “python”. This looks a lot like the json format you are using.
So here’s my problem. I can REPRODUCE a return for a single issn api request as follows by copying and pasting the return into a python script and calling it “a”:
will render a list of all 4 of the ISSN’s in the above output.
My problem is that I cannot for the life of me figure out how to actually generate the above (a) return as a single value using Python. This would be essential in making it possible form e to iterate through a list of inputted ISSN’s as I can do now using the OCLC .csv format.
The best I can do is get Python to write this out by doing the following:
for t in x:
t1 = str( t, encoding='utf8' )
print(t1)
This writes the same result out in the results, but NOT as a single parsable value.
Anything I do to compile this print into single array of any sort gets me an error when I try to parse by searching on a key value, by insisting that key values must be in an integer form.
I keep thinking that there is something really obvious that I am missing here.
Tim
The text was updated successfully, but these errors were encountered:
From Tim - moved here from learn-git
I have been successful in running an OCLC API via python to generate a list of ISSN’s associated with a list of inputted ISSNs.
This has been very useful, and replaces a tool that used to be available through SFX.
I was able to do this be taking the data in a .csv format, and manipulating that data by appending it to Python lists, all of which is close to what I would have done with PHP arrays.
But I GOT CURIOUS over another format the OCLC offers called “python”. This looks a lot like the json format you are using.
So here’s my problem. I can REPRODUCE a return for a single issn api request as follows by copying and pasting the return into a python script and calling it “a”:
a={
'stat':'ok',
'group':[{
'rel':'this',
'list':[{
'issn':'0193-5615',
'form':'JB'},
{
'issn':'1559-9167',
'form':'JB'},
{
'issn':'1548-1409',
'form':'JD'},
{
'issn':'1937-4402',
'form':'JD'}]}]}
I can then parse this in a variety of ways:
For example:
print(((a['group'][0])['list'][3])['issn'])
will render 1937-4402
or a more complicated process:
b=(a['group'][0])
c=(b['list'])
l=len(c)
for i in range(l):
print(c['issn'])
will render a list of all 4 of the ISSN’s in the above output.
My problem is that I cannot for the life of me figure out how to actually generate the above (a) return as a single value using Python. This would be essential in making it possible form e to iterate through a list of inputted ISSN’s as I can do now using the OCLC .csv format.
The best I can do is get Python to write this out by doing the following:
url='http://xissn.worldcat.org/webservices/xid/issn/2161-9417?method=getForms&format=python'
x = urllib.request.urlopen(url)
print(x)
for t in x:
t1 = str( t, encoding='utf8' )
print(t1)
This writes the same result out in the results, but NOT as a single parsable value.
Anything I do to compile this print into single array of any sort gets me an error when I try to parse by searching on a key value, by insisting that key values must be in an integer form.
I keep thinking that there is something really obvious that I am missing here.
Tim
The text was updated successfully, but these errors were encountered: