web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Python Scripting PAD

(0) ShareShare
ReportReport
Posted on by
  1. Hello, I am currently making a flow which extracts data from SAP and stores that data in a multiple excel files on a folder on my desktop. From that data I create a weekly report by using pythons to filter through and find the necessary data. I want to be able to run this python script through power automate however I'm not sure how it would work as the python code creates a copy of an existing file and then creates necessary changes from user input. My main concern is being able to save the report I created. Will the python code I run create and save that report in the folder path I give or is there another way of doing this 
 
I have the same question (0)
  • VishnuReddy1997 Profile Picture
    2,656 Super User 2026 Season 1 on at

    Hi @Maad ,

    1. Prepare Your Python Script:
    • Modify your Python script to accept the target folder path and report file name as arguments. This allows PAD to dynamically set these values during execution.
    2. Run Python Script in PAD:
    • In PAD, use the "Run Python Script" action.
    • In the script path, specify the location of your Python script.
    • Define two variables in PAD:
    o FolderPath: This will store the location where you want to save the report. You can set this before running the script.
    o ReportName: This will hold the desired name for the generated report. This can be a static value or built dynamically based on the extracted data.
    3. Pass Arguments to Python Script:
    • In the "Run Python Script" action, configure the arguments:
    o Add two arguments, one for FolderPath and another for ReportName.
    o Set the value of each argument to the corresponding PAD variable (%FolderPath% and %ReportName%).
    4. Python Script Saves the Report:
    • Inside your Python script, use the provided FolderPath and ReportName to construct the complete file path where the report should be saved.
    • Use libraries like pandas or csv to write the final report data to the constructed file path.

     

    Please find the Example:

     

    import pandas as pd
    
    def generate_report(folder_path, report_name, data):
     # Process and filter data
    
     # Create the report dataframe
     report_df = pd.DataFrame(data)
    
     # Construct the file path
     file_path = f"{folder_path}/{report_name}.xlsx"
    
     # Save the report to the specified location
     report_df.to_excel(file_path, index=False)
    
    # Get folder path and report name from PAD variables
    folder_path = sys.argv[1]
    report_name = sys.argv[2]
    
    # Generate report using your data processing logic
    generate_report(folder_path, report_name, your_extracted_data)

     

     

    Remember Python in PAD support only 2.7 and 3.4 Versions.

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard