from scholarly import scholarly
import pandas as pd
author_name = ["Rohan, Kelly J.","kurt ackermann"]
df = pd.DataFrame(author_name, columns=['author_name'])
df.head()
def read_author_data(author_name):
print("Searching the name in Google scholar -- {0:s}".format(author_name))
search_query = scholarly.search_author(author_name)
author = scholarly.fill(next(search_query))
if "vermont" in author["affiliation"].lower():
print(author)
try:
home_page=author['homepage'] #all user don't have it, put it seperate
except:
home_page=""
pass
a_data = {
"name": author["name"],
"affiliation": author["affiliation"],
"area_of_interest":author['interests'],
}
else:
a_data = {
"name": "",
"affiliation": "",
"area_of_interest":""
}
return a_data
def author_details(df):
cols = ["name", "affiliation", "area_of_interest"]
df_author=pd.DataFrame(columns=cols)
for i,rows in df.iterrows():
try:
a_details=read_author_data(rows[author_name])
df_a=pd.DataFrame(a_details.items()).T
df_a.columns = df_a.iloc[0]
print(df_a.shape)
df_author=df_author.concat(df_a,ignore_index=True)
except Exception:
#a_details={}
pass
return df_author
Final line to call the function
author_details(df)
error is Getting an empty row, but there should be values for Rohan, Kelly J but there is no data for it.
The expected output is to get the details and store them in the data frame.