Best way to edit an excel spreadsheet stored on SharePoint?

Hey everyone!

I have a quick question for anyone familiar with Python and SharePoint. I was hoping to automate some of my data entry work with python: I collect data and then enter it into several different excel spreadsheets stored on the company SharePoint for different departments to use. I’m not sure what the right approach is for accessing SharePoint files with Python though. Has anyone done something like this before? Have any tips for helping me get started? The spreadsheets are often left open by other users and are worked on during the day.

Many thanks!

While an API for SharePoint exists, a simpler approach is to ‘mirror’ the SharePoint content on the OneDrive directory of the Windows filesystem. That’s a one-time action; look for “Add shortcut to OneDrive” in the “…” menu.

Then the Excel file is ‘just’ a local file, which you can update (daily) with a Python script using e.g. openpyxl or polars libraries (see PyPI). The mirroring will ensure that (with a small delay) the same content is available locally (on your drive), on OneDrive, on SharePoint, and in Teams.

1 Like