Skip to main content

Notifications

Community site session details

Community site session details

Session Id : a904TEdXqolnNZgaoxvuO7
Power Automate - Power Automate Desktop
Unanswered

How to pass a flow variable of data table type from Power Automate to a Python script?

Like (0) ShareShare
ReportReport
Posted on 8 Feb 2023 02:44:47 by 3

I want to perform some complex operations on an Excel document, and I am not very familiar with Power Automate, but I can write a python script to handle the Excel file. Therefore, I want to embed my python script into Power Automate, which makes it easier for me to debug my python script in real time and also makes it convenient for my colleagues who are not familiar with programming to carry out the work through the work flow I shared.

 

I started an Excel file from a local folder through Power Automate and outputted a flow variable called "ExcelInstance". I then read the values of all cells in the worksheet and stored them in a flow variable called "ExcelData". Now, I want to continue with the next step by adding an action to run a python script. However, I am having trouble passing the flow variable "ExcelData" to the python script so that "ExcelData" can be converted into a DataFrame in python.

 

Could you please tell me how I can pass "ExcelData" to Python through code? Thank you very much for your help!

  • Agnius Bartninkas Profile Picture
    10,045 Most Valuable Professional on 24 Oct 2023 at 06:29:15
    Re: How to pass a flow variable of data table type from Power Automate to a Python script?

    Python 2.0 does have imports. It's just that the syntax is different and not all libraries are supported. @Joe007 , officially, Pandas support Python 2.7 and some of the Python 3.x versions, so 2.0 may not be supported. But you can try following the instructions here on how to install it and try it out yourself: https://pandas.pydata.org/pandas-docs/version/0.23/install.html

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Pavel_NaNoi Profile Picture
    1,072 on 23 Oct 2023 at 14:09:36
    Re: How to pass a flow variable of data table type from Power Automate to a Python script?

    Can't, PAD uses python 2.0, which if I remember correctly, didn't have imports.

  • Joe007 Profile Picture
    2 on 21 Oct 2023 at 13:50:24
    Re: How to pass a flow variable of data table type from Power Automate to a Python script?

    It worked however it is of string type.
    How we can import pandas within python script?

  • Shahabas Profile Picture
    3 on 09 Feb 2023 at 06:26:25
    Re: How to pass a flow variable of data table type from Power Automate to a Python script?

    Hi @momlo,

     

    Thank you for your reply.

    I tried the method you mentioned, but it didn't work. 

    I find that in this method, the author has passed an Input/Output variable into python, and the variable content is a string. In the problem I encountered, the variable is Flow variable, and the content of the variable is a Datatable. I saw someone say that you can put a $ sign in front of the variable to indicate that it is a Datatable, like this:

    DataTable = """$%ExcelData%"""

    But it still doesn't work:(

     

    If you have any ideas, please feel free to let me know. Many Thanks!

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on 08 Feb 2023 at 09:06:14
    Re: How to pass a flow variable of data table type from Power Automate to a Python script?

    Hi @Shahabas 

    Declare python variable and set to the PAD variable:

    song_list = """%SongList%"""

     

    Taken from here:

    https://www.wiseowl.co.uk/blog/s2986/power-automate-desktop-python-script.htm

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Power Automate Desktop

#1
eetuRobo Profile Picture

eetuRobo 4 Super User 2025 Season 1

#2
KO-05050229-0 Profile Picture

KO-05050229-0 2

#2
stampcoin Profile Picture

stampcoin 2

Overall leaderboard