Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to download XLSX file from DOI link?

I want to download two files automatically from Python for a reproducible statistical analysis.

These links

I tried

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import requests

url = 'https://doi.org/10.1371/journal.pone.0282068.s001'

response = requests.get(url)

I suspect that the file is actually the content of response.content, which appears to be a bunch of encoded information (e.g. \xe2\x81a\xe4\x1dq\xbe9~3\x94\x885\xba\xc8\x9bz\'~\x1c)X>\xaaXyg\x929\xf84\xc2\x06\t\n x5\).

How do I download these files and save them as XLSX files?

>Solution :

you need to save the content into the file.

import requests

url = 'https://doi.org/10.1371/journal.pone.0282068.s001'

response = requests.get(url)
data = response.content

with open('filename.xlsx', 'wb') as f:
    f.write(data)

your content will be saved in file filename.xlsx

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading