У меня возникли проблемы с чтением файла SharePoint Excel с использованием Python Pandas и Office 365. Он выводит «Аутентификация прошла успешно», но имеет несколько ошибок:
Traceback (most recent call last): File "/Users/gfgdfg/Try.py", line 28, in <module> df = pd.read_excel(bytes_file_obj, sheetname = None) File "/Users/venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 299, in wrapper return func(*args, **kwargs) TypeError: read_excel() got an unexpected keyword argument 'sheetname'
Мой полный код:
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.files.file import File
import pandas as pd
url = 'https://dfsdfksdfhk.sharepoint.com/:x:/s/dkfjsldkfjldjfC4IT3'
username = 'email@outlook.com'
password = 'mypassword'
ctx_auth = AuthenticationContext(url)
if ctx_auth.acquire_token_for_user(username, password):
ctx = ClientContext(url, ctx_auth)
web = ctx.web
ctx.load(web)
ctx.execute_query()
print("Authentication successful")
response = File.open_binary(ctx, url)
#save data to BytesIO stream
bytes_file_obj = io.BytesIO()
bytes_file_obj.write(response.content)
bytes_file_obj.seek(0) #set file object to start
#read excel file and each sheet into pandas dataframe
df = pd.read_excel(bytes_file_obj, sheetname = None)
print(df)```