def journal_numberof_first_last_authorship(author_id):
    '''Input is author scopus id and get all publications 
     from Scopus database. Filter the journal publications and
     return the number of first, last authorship of the researcher
     
    Parameter
    ----------
    author_id : int or str 
                Scopus id of Author 
    
    Returns
    ----------
    first, last : obj                
               pandas dataframe object  
               number of first and last author in journals    
    '''
    assert isinstance(author_id, (str, int))

    au = AuthorRetrieval(author_id)
    publications = pd.DataFrame(au.get_document_eids(refresh=False))
    articles = publications[publications['aggregationType'] == 'Journal']

    first = articles[articles['author_ids'].str.startswith(author_id)]
    last = articles[articles['author_ids'].str.endswith(author_id)]

    n_first, n_last = len(first), len(last)

    return (n_first, n_last)
            given_name = fisrtLetter
            authorSearch = AuthorSearch('AUTHLAST(' + family_name +
                                        ') and AUTHFIRST(' + given_name +
                                        ') and AFFIL(University)')
            authors = authorSearch.authors
        if authors == None:
            print("no result")
            continue
        author = authors[0]
        print(author[0])

        authorRetrieval = AuthorRetrieval(author[0])
        eid = authorRetrieval.eid
        first_name = authorRetrieval.given_name
        last_name = authorRetrieval.surname
        docs = ','.join(authorRetrieval.get_document_eids())
        citation_count = authorRetrieval.citation_count
        document_count = authorRetrieval.document_count
        orcid = authorRetrieval.orcid
        name_variants = authorRetrieval.name_variants
        coauthors = authorRetrieval.get_coauthors
        coauthors_count = authorRetrieval.coauthor_count
        new_row = [
            first_name, last_name, eid, orcid, citation_count, document_count,
            name_variants, docs, coauthors_count
        ]
        csvData.append(new_row)

with open('cis_academics.csv', 'w', encoding='utf-8') as csvFile:
    writer = csv.writer(csvFile)
    writer.writerows(csvData)
for author, _ in df.groupby('CONTACT_SURNAME'):
    researcher = df.loc[(df['CONTACT_SURNAME']==author)]
    eids = researcher['SCOPUS_ID'].tolist()
    scopus_eids = [str(eid) for eid in eids if eid is not np.nan]
    row = {'Author': author, 'eids': scopus_eids}
    
    #finding the author scopus id from co-authors list of the publication
    #Evoke the scival abstract api get co-authors from eid_authorid function
    try:
        researchers = eid_authorid(row['eids'][0])
        author_scopus_id = researchers[row['Author']]
        #Call Scopus Author API and get pbulications EIDs match to authors
        au = AuthorRetrieval(author_scopus_id)
    
    
        #Retrive all publications of the retive author
        pubs = au.get_document_eids(refresh=False, cursor=False)
    #Get the subset which match to SCOPUS database and Central publication repos
        papers = set(pubs)
        match_publications = papers.intersection(row['eids'])
    
    #Validation scores for the authors
        match_score = len(match_publications)/len(row['eids'])
    
        data.loc[data['CONTACT_SURNAME']==author,'Scopus_id'] = author_scopus_id
        data.loc[data['CONTACT_SURNAME']==author,'publication_score'] = match_score 
    except:
        continue
    
    
data.to_csv('data/medicine_scopus_ids.csv', index=False)