def papers_by_country_with_affs_csv(req, country): req.content_type = 'text/csv; charset=utf-8' req.headers_out['content-disposition'] = ('attachment; ' 'filename=papers_by_country.csv') ## print the list of linkt to the articles count = 1 print >> req, country search = "100__w:'%s' OR 700__w:'%s'" % (country, country) res = perform_request_search(p='%s' % (search, )) print >> req, "#;Title;Journal;DOI;Inspire record;Author;Affiliations" if len(res): for rec_id in res: author_count = 11 rec = get_record(rec_id) title = '' authors = '' journal = '' doi = '' inspire_record = '' if '245' in rec: title = re.sub("<.*?>", "", rec['245'][0][0][0][1]) for sub in rec['773'][0][0]: if 'p' in sub[0]: journal = sub[1] doi = get_doi(rec_id) if '035' in rec: for f in rec['035'][0][0]: if 'a' in f: inspire_record = 'http://inspirehep.net/record/%s' % ( f[1], ) print >> req, "%s;%s;%s;%s;%s;;" % (count, title, journal, doi, inspire_record) if '100' in rec: author = rec['100'][0][0][0][1] affiliations = record_get_field_values(rec, tag='100', code='v') print >> req, ";;;;;%s;%s" % (author, " | ".join(affiliations)) if '700' in rec: for auth in rec['700']: author = auth[0][0][1] affiliations = field_get_subfield_values(auth, code='v') print >> req, ";;;;;%s;%s" % (author, " | ".join(affiliations)) count += 1
def papers_by_country_csv(req, country): req.content_type = 'text/csv; charset=utf-8' req.headers_out['content-disposition'] = ('attachment; ' 'filename=papers_by_country.csv') ## print the list of linkt to the articles count = 1 print >> req, country search = "100__w:'%s' OR 700__w:'%s'" % (country, country) res = perform_request_search(p='%s' % (search, )) print >> req, "#;Title;Author;Journal;DOI;Inspire record" if len(res): for rec_id in res: author_count = 11 rec = get_record(rec_id) title = '' authors = '' journal = '' doi = '' inspire_record = '' if '245' in rec: title = re.sub("<.*?>", "", rec['245'][0][0][0][1]) if '100' in rec: authors = rec['100'][0][0][0][1] if '700' in rec: for auth in rec['700']: if author_count > 1: authors += " / %s" % (auth[0][0][1], ) author_count -= 1 elif author_count == 1: authors += " / et al" author_count -= 1 else: break for sub in rec['773'][0][0]: if 'p' in sub[0]: journal = sub[1] doi = get_doi(rec_id) if '035' in rec: for f in rec['035'][0][0]: if 'a' in f: inspire_record = 'http://inspirehep.net/record/%s' % ( f[1], ) print >> req, "%s;%s;%s;%s;%s;%s" % (count, title, authors, journal, doi, inspire_record) count += 1
def papers_by_country_csv(req, country): req.content_type = 'text/csv; charset=utf-8' req.headers_out['content-disposition'] = ('attachment; ' 'filename=papers_by_country.csv') ## print the list of linkt to the articles count = 1 print >> req, country search = "100__w:'%s' OR 700__w:'%s'" % (country, country) res = perform_request_search(p='%s' % (search,)) print >> req, "#;Title;Author;Journal;DOI;Inspire record" if len(res): for rec_id in res: author_count = 11 rec = get_record(rec_id) title = '' authors = '' journal = '' doi = '' inspire_record = '' if '245' in rec: title = re.sub("<.*?>", "", rec['245'][0][0][0][1]) if '100' in rec: authors = rec['100'][0][0][0][1] if '700' in rec: for auth in rec['700']: if author_count > 1: authors += " / %s" % (auth[0][0][1],) author_count -= 1 elif author_count == 1: authors += " / et al" author_count -= 1 else: break for sub in rec['773'][0][0]: if 'p' in sub[0]: journal = sub[1] doi = get_doi(rec_id) if '035' in rec: for f in rec['035'][0][0]: if 'a' in f: inspire_record = 'http://inspirehep.net/record/%s' % (f[1],) print >> req, "%s;%s;%s;%s;%s;%s" % (count, title, authors, journal, doi, inspire_record) count += 1
def papers_by_country_with_affs_csv(req, country): req.content_type = 'text/csv; charset=utf-8' req.headers_out['content-disposition'] = ('attachment; ' 'filename=papers_by_country.csv') ## print the list of linkt to the articles count = 1 print >> req, country search = "100__w:'%s' OR 700__w:'%s'" % (country, country) res = perform_request_search(p='%s' % (search,)) print >> req, "#;Title;Journal;DOI;Inspire record;Author;Affiliations" if len(res): for rec_id in res: author_count = 11 rec = get_record(rec_id) title = '' authors = '' journal = '' doi = '' inspire_record = '' if '245' in rec: title = re.sub("<.*?>", "", rec['245'][0][0][0][1]) for sub in rec['773'][0][0]: if 'p' in sub[0]: journal = sub[1] doi = get_doi(rec_id) if '035' in rec: for f in rec['035'][0][0]: if 'a' in f: inspire_record = 'http://inspirehep.net/record/%s' % (f[1],) print >> req, "%s;%s;%s;%s;%s;;" % (count, title, journal, doi, inspire_record) if '100' in rec: author = rec['100'][0][0][0][1] affiliations = record_get_field_values(rec, tag='100', code='v') print >> req, ";;;;;%s;%s" % (author, " | ".join(affiliations)) if '700' in rec: for auth in rec['700']: author = auth[0][0][1] affiliations = field_get_subfield_values(auth, code='v') print >> req, ";;;;;%s;%s" % (author, " | ".join(affiliations)) count += 1
def _get_arxiv_id_from_inspire(record): url = 'https://inspirehep.net/search?p=doi:{0}&of=xm' data = urllib.urlopen(url.format(get_doi(int(record.record_id)))).read() inspire_rec = create_record(data)[0] return _find_arxiv_id(inspire_rec)