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!
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.
Can't, PAD uses python 2.0, which if I remember correctly, didn't have imports.
It worked however it is of string type.
How we can import pandas within 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!
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
eetuRobo
4
Super User 2025 Season 1
KO-05050229-0
2
stampcoin
2