1

Seek your guidance, I am new @Python and in learning phase.

Problem Statement: I want to connect & Download the xlsx file from my office SharePoint 2013 site.

Steps so far:

import sharepy
s = sharepy.connect("https://office.XXX.com/sites/pkdyns")
r = s.getfile("https://office.XXX.com/sites/pkdyns/Shared%20Documents/YYYY.xlsx")
r = s.getfile("https://office.XXX.com/sites/pkdyns/Shared%20Documents/YYYY.xlsx", filename="/PYTHON/YYYY.xlsx")

After this I dont see the downloaded file, not sure if it ran or not, using Jupyter Notebook but it didnt throw up any error. Please suggest.

1

1 Answer 1

2

sharepy library seems to only support sharepoint online.

SharePy - Simple SharePoint Online authentication for Python

Below is a sample about how to download file from sharepoint, you may take a reference( it uses another library):

from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.file import File

ctx = ClientContext.connect_with_credentials(url,UserCredential(username, password))
web = ctx.web
ctx.load(web)
ctx.execute_query()
print "Web title: {0}".format(web.properties['Title'])
 
path = "../../tests/data/SharePoint User Guide.docx"
response = File.open_binary(context, "Shared Documents/SharePoint User Guide.docx")
response.raise_for_status()
with open(path, "wb") as local_file:
     local_file.write(response.content)

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.