import os import sys # Allow this program to be executed directly from the 'examples' directory. try: thisdir = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(thisdir, '..')) except: sys.path.insert(0, '..') import sidewall from sidewall import dimensions if len(sys.argv) > 1 and sys.argv[1] == '-d': sidewall.set_debug(True) dimensions.login() print('sending query to Dimensions') results = dimensions.query( 'search publications in title_only for "SBML" where year=2003 return publications' ) print('got back {} publications'.format(len(results))) for p in results: print('-' * 70) print('{}'.format(p.title)) for a in p.authors: print('{} {} ({})'.format(a.first_name, a.last_name, a.orcid))
acronym = (' (' + org.acronym + ')') if org.acronym else '' country = (' -- ' + org.country) if org.country else '' return org.name + acronym + country # Main program # ............................................................................. # The rest of this file is the actual code for the example. import sidewall from sidewall import dimensions print('Logging in to Dimensions') dimensions.login() print('Sending query to Dimensions') grants = dimensions.query('search grants where research_orgs.id = "grid.20861.3d" return grants') print('Got back {} grants'.format(len(grants))) for g in grants: print('') print('Title: {}'.format(g.title)) print('Funder: {}'.format(', '.join(org_info(org) for org in g.funders))) print('Project number: {}'.format(g.project_num)) print('Project year(s): {}'.format(', '.join(str(y) for y in g.active_year))) if g.funding_usd: amount = '$' + intcomma(int(g.funding_usd)) else: amount = 'N/A' print('Funded amount: {}'.format(amount)) print('Recipient organizations:') if g.research_orgs:
sys.path.insert(0, '..') import sidewall from sidewall import dimensions if len(sys.argv) > 1 and sys.argv[1] == '-d': sidewall.set_debug(True) dimensions.login() print('Sending query & building objects.') pr = cProfile.Profile() pr.enable() results = dimensions.query( 'search publications where research_orgs.id = "grid.20861.3d" return publications', limit_results=1000) # Creating list forces all 1000 results to be fetched and Sidewall objects built list(results) pr.disable() print('Done.') print('') print('Reminder: "tottime" is the total time spent in the function alone.') print( '"cumtime" is the total time in the function plus all functions it calls.') print('') stats = pstats.Stats(pr) stats.sort_stats('tottime') stats.print_stats(10)
import sys try: thisdir = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(thisdir, '..')) except: sys.path.insert(0, '..') # Main program # ............................................................................. # The rest of this file is the actual code for the example. from sidewall import dimensions print('Logging in to Dimensions') dimensions.login() print('Sending query to Dimensions') pubs = dimensions.query( 'search publications where research_orgs.id = "grid.20861.3d" return publications' ) print('Got back {} publications'.format(len(pubs))) for count, p in enumerate(pubs, 1): author = p.authors[0].last_name + (' et al.' if len(p.authors) > 1 else '') title = '"' + p.title[:37] + ('...' if len(p.title) > 37 else '') + '"' print('[{:5}] {} - {:35} {:42} {}'.format(count, p.year, p.doi, title, author)) print('Done.')