Created
February 10, 2019 08:46
-
-
Save dimnikolos/f7cc89ac53245472c597545b2f101790 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
github.com/dimnikolos | |
2019 | |
""" | |
import re | |
import scholarly | |
with open('citescount.html','w',encoding='utf-8') as resf: | |
#cites.txt is your bibliography/reference in a text file | |
#a line per reference | |
with open('cites.txt','r',encoding='utf-8') as citef: | |
resf.write('<html>') | |
resf.write('<head>') | |
resf.write('<meta charset="UTF-8">') | |
resf.write('<title>') | |
resf.write('Citation count') | |
resf.write('</title>') | |
resf.write('</head>') | |
resf.write('<body>') | |
resf.write('<table border="1">') | |
curLine = citef.readline() | |
while (curLine): | |
m = re.match("^(.*?),.*?\)(\.)?(.*?)\..*",curLine) | |
if (m): | |
#print(m.group(1),m.group(3)) | |
author = str(m.group(1)) | |
authorTitle = str(m.group(1))+' '+str(m.group(3)) | |
authorTitle = authorTitle.replace('-',' ') | |
pubs = scholarly.search_pubs_query(authorTitle) | |
try: | |
citedby = next(pubs).citedby | |
except (AttributeError,StopIteration): | |
citedby = -1 | |
print(author,citedby) | |
else: | |
citedby = -1 | |
resf.write('<tr><td>'+curLine+'</td><td>'+ str(citedby) + '</td></tr>') | |
curLine = citef.readline() | |
resf.write('</table></body></html>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment