1

I am having trouble reading a SharePoint excel file using Python Pandas and Office 365. It is outputting "Authentication Successful" but has a few errors stating:

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'

My full Code is:

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 protected]'
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)```

1 Answer 1

1

This question was answered here TypeError with pandas.read_excel. All in all, just replace sheetname with sheet_name in your code. Should work well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.