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

Notifications

Announcements

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 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard