Enhancing SharePoint Operations with Python: New Functions Added to the sharepoint_utils Package
Omkar Sutar
Data Analyst | Power BI Expert | Power Automate Specialist | Python Aficionado
Hello, fellow Python enthusiasts and SharePoint users! I’m excited to announce that I’ve added three new functions to my Python package, sharepoint_utils, making it even more powerful and user-friendly for those who work with SharePoint. The package, which can be found here, was initially equipped with three functions:
Now The newly added functions are:
领英推荐
Here’s a simple example of how these functions can be used:
# Import necessary functions from the sharepoint_utils module
from sharepoint_utils import connect_to_sharepoint, get_folder_urls, get_file_paths, read_file_from_sharepoint, upload_dataframe_to_sharepoint
# Connect to the SharePoint using credentials and URL
sharepoint_context = connect_to_sharepoint("username", 'password', 'sharepoint_url')
# Get the URLs of folders in the SharePoint document library
document_library_relative_url = '/sites/YourSite/Shared Documents'
folder_urls = get_folder_urls(sharepoint_context, document_library_relative_url)
# Extract specific folders from the list of URLs
desired_folder_1 = folder_urls[1]
desired_folder_2 = get_folder_urls(sharepoint_context, desired_folder_1)[0]
desired_folder_3 = get_folder_urls(sharepoint_context, desired_folder_2)[0]
# Get the paths of files within the desired folder
file_paths = get_file_paths(sharepoint_context, desired_folder_3)
# Read a file from SharePoint into a DataFrame
data_frame = read_file_from_sharepoint(sharepoint_context, file_paths[0])
# Perform necessary transformations on the DataFrame
data_frame = data_frame.head(50)
# Upload the transformed DataFrame to SharePoint as a CSV file
upload_dataframe_to_sharepoint(sharepoint_context, desired_folder_2, data_frame, "Uploaded_from_python.csv")
These enhancements make the sharepoint_utils package a more comprehensive tool for Python users working with SharePoint. I hope you find these updates useful and I look forward to your feedback!