Forum Discussion

Retaining3118's avatar
Retaining3118
Copper Contributor
Dec 04, 2024

How to run a Python script on a SharePoint list in order to generate a PowerPoint file?

Hi everyone,

I currently have a local Python script that takes a CSV file (downloaded manually from SharePoint using the "Export as CSV" button) as input, processes the data, and generates a custom PowerPoint file using on a predefined template stored in the script's folder.

The process works fine locally, but I want to streamline it so users don't have to download the CSV file and script locally and manually. Instead, I'd like to:

* Run the Python script directly on SharePoint.
* Provide a simple button in SharePoint that users can click to trigger the script.
* Have the script fetch the exported CSV file directly from SharePoint, process it, and then download the generated PowerPoint file 

Any advice, best practices, or examples would be greatly appreciated, thanks

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    SharePoint, by itself, doesn't provide native support for executing Python scripts directly within its environment...so far I know.

    To streamline the process of running a Python script that interacts with SharePoint data and generates a PowerPoint file, you'll need to leverage several tools and services within Microsoft 365 and SharePoint Online.

    To implement the solution to run a Python script on a SharePoint list and generate a PowerPoint file, they could consider these steps:

    Host the Python script on an external service such as Azure Functions or a web server.

    Set up Power Automate to trigger the Python script when a user clicks a button in SharePoint.

    Use SharePoint REST API or Microsoft Graph API in Python to get the CSV file directly from SharePoint.

    Process the CSV data and generate the PowerPoint file using libraries such as Pandas and Python-PPTX.

    Return the generated PowerPoint file to the user by either uploading it to SharePoint or sending a download link via Power Automate.

    This approach provides users with a seamless experience without requiring them to manually download CSV files or run scripts locally.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

Resources