vdmitriyev / orcidpyclient

A wrapper client around API of orcid.org
Other
6 stars 4 forks source link

Searching for non existent authors #6

Closed flouland closed 3 years ago

flouland commented 3 years ago

Is it possible to get some sort of result if an author does not have an orcid id? I'm trying to search for authors via their first and last name. If an author does not have a orcid id / orcid profile is there any way to get a result which indicates that no author has been found via the search function?

vdmitriyev commented 3 years ago

Hope. that I understood your question right. I assume that you have to deal with StopIteration exception in Python, to see if the search results haven't got any authors found. Here is an example for you, that I hope it helps you further:

import sys
import pyorcid
authors = pyorcid.search('family-name:wilbanksTestName+AND+given-names:john')

try:
    first = next(authors)
except StopIteration as ex:
   print('No authors found')
   sys.exit(0)

print(first.family_name)
for author in authors:
    print(author.family_name)
flouland commented 3 years ago

Thank you for the fast reply! This solved my problem!