Search code examples
pythonxlsxxlspython-3.8

How to Extract the result from python into a xls file


I'm a novice in python and I need to extract references from scientific literature. Following is the code I'm using

from refextract import extract_references_from_url
references = extract_references_from_url('https://arxiv.org/pdf/1503.07589.pdf')
print(references)

So, Please guide me on how to extract this printed information into a Xls file. Thank you so much.


Solution

  • You could use the pandas library to write the references into excel.

    from refextract import extract_references_from_url
    import pandas as pd
    
    references = extract_references_from_url('https://arxiv.org/pdf/1503.07589.pdf')
    print(references)
    
    # convert to pandas dataframe
    dfref = pd.DataFrame(references)
    
    # write dataframe into excel
    dfref.to_excel('./refs.xlsx')