Python-download excel (xlsx) file from sharepoint to my local drive is not working

Viewed 132

I am trying to download the xlsx file which is in company sharepoint to my local drive to process it furthur using pandas. Though the connection to the sharpoint gives me Response[200], test.xlsx in my local drive is corrupted and I am not able to open it.

import requests

from requests.auth import HTTPBasicAuth
file = "company sharepoint .xlsx"
username = 'myUsername'
password = 'myPassword'

resp=requests.get(file, auth=HTTPBasicAuth(username, password))
print(resp)

output = open('test.xlsx', 'wb')
output.write(resp.content)
output.close()
0 Answers
Related