quick.
I have an XLSX file located on a sharepoint disk and cannot open it with openpyxl in python, it works well if it is stored on my local disk.
I have tried this.
from openpyxl import load_workbook
wb = load_workbook('https://content.potatocompany.com/workspaces/PotatoTeam/Shared Documents/XYZ errors/XYZ Errors_Confirm.xlsx')
Throws this exception:
C:\Anaconda\lib\site-packages\openpyxl\reader\excel.py in load_workbook(filename, use_iterators, keep_vba, guess_types, data_only)
123 except (BadZipfile, RuntimeError, IOError, ValueError):
124 e = exc_info()[1]
--> 125 raise InvalidFileException(unicode(e))
126 wb = Workbook(guess_types=guess_types, data_only=data_only)
127
InvalidFileException: [Errno 22] invalid mode ('rb') or filename: 'https://...
Am I missing something? I need to read the contents of one of the sheets in python.
EDIT:
Using crussell's advice, I get 401 UNAUTHORIZED :
import requests
import urllib
from openpyxl import load_workbook
from requests.auth import HTTPBasicAuth
file = "https://content.potatocompany.com/workspaces/PotatoTeam/Shared Documents/XYZ errors/XYZ Errors_Confirm.xlsx"
username = 'PotatoUser'
password = 'PotatoPassword'
resp=requests.get(file, auth=HTTPBasicAuth(username, password))
print(resp.content)
It seems that sharepoint and requests are incompatible with both Digest authentication and basic authentication
http://docs.python-requests.org/en/latest/user/authentication/
source
share