Forum Discussion
User_212
2 years agoNew Member
Notebooks
What is the syntax for setting up a notebook to ingest data from an online excel file using the download url?
GilbertQ
Super User
2 years agoHi User_212
I would recommend doing a search to find the exact syntax for downloading an Excel file.
Here is an example I got from ChatGTP
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.client_credential import ClientCredential
from office365.runtime.auth.user_credential import UserCredential
# Define your SharePoint site and file details
site_url = "https://yourcompany.sharepoint.com/sites/yoursite"
file_url = "/sites/yoursite/Shared Documents/yourfile.xlsx" # The relative URL of the file in the document library
# Authentication details
username = "[email protected]"
password = "your_password"
# Create a ClientContext object
ctx = ClientContext(site_url).with_credentials(UserCredential(username, password))
# Download the file
response = ctx.web.get_file_by_server_relative_url(file_url).download("./downloaded_file.xlsx").execute_query()
print("File has been downloaded successfully")
User_212
2 years agoNew Member
Thanks for your response, however its not a sharepoint file I am attempting to ingest its just some company data from an online source in excel format. I've tried ChatGPT but not having any luck unfortunately.