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 iterate through...
Power Automate
Answered

How to iterate through a data table using python script in PAD?

(0) ShareShare
ReportReport
Posted on by 1,714 Moderator

Say I have the following table:

NathanAlvares24_0-1700200333653.png

 

Now what I am trying to achieve is to copy the contents of this data table into another data table. I know this can be done using 'Set variable' action or even 'Insert row into data table' action. But I want to try using python script.

 

My flow:

NathanAlvares24_1-1700200664033.png

 

So I tried using that script to store the first value of the Name column but I can't seem to access the data table as it doesn't show in the output. Can anyone provide assistance in this? I would be much appreciated.

 

Thank you,

Nathan

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Can you share a screenshot of the script inside the action itself?

    Also, have you enabled the ScriptError variable for debugging to see if it throws an error?

    -------------------------------------------------------------------------

    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.

  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @Agnius !

     

    NathanAlvares24_0-1700210525916.png

    Script:

    result = ["%MyDataTable[0]['Name']%"]

    print(result)

    This is just something I was testing out to get the first row of Name column which should result in 'John' but unable to access the data table.

     

    Thank you,

    Nathan

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Does it return anything into ScriptError?

  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @Agnius !

     

    Thanks I just checked and made out my mistake.

    Now another thing just wanted to ask is that:

     

    Say suppose I want to access the first row of that data table and so on (since I want to iterate through each row of the data table:

    NathanAlvares24_0-1700214186482.png

    But I want the output to store it as a data row. Is it possible? Like in python normally we use libraries like pandas, numpy and all. But sadly, this doesn't work in PAD for some reason. If you could assist me in this, I would be grateful.

     

    Thanks,

    Nathan

  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    I have used something like this:

    name = """%MyDataTable[countName]['Name']%"""
    email = """%MyDataTable[countEmail]['Email']%"""

    # return this to Power Automate Desktop
    print(name, email)

     

    NathanAlvares24_0-1700216222544.png

    But get this error. I mean there are only two values but not sure of error

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The output of the Run Python script action will always be a single string in PAD, regardless of what you print. It will always be concatenated into a single string. So, if you want to do it like this, you should use Split text on the output of the script before adding it as a row to a data table.

    -------------------------------------------------------------------------
    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

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 784

#2
Valantis Profile Picture

Valantis 581

#3
Haque Profile Picture

Haque 545

Last 30 days Overall leaderboard