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 Platform Community / Forums / Power Automate / How to pass a flow var...
Power Automate
Unanswered

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

(0) ShareShare
ReportReport
Posted on 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!

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    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

     

  • Shahabas Profile Picture
    3 on at

    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!

  • Joe007 Profile Picture
    2 on at

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

  • Pavel_NaNoi Profile Picture
    1,074 on at

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

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    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.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 233 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 178

Last 30 days Overall leaderboard