Skip to main content

Notifications

Community site session details

Community site session details

Session Id : XTNtjyRXJCH+vsGu6hh5hA
Power Automate - Building Flows
Suggested answer

Create CSV table from array

Like (1) ShareShare
ReportReport
Posted on 26 Jul 2024 08:31:44 by 63
Hi,
 
I have an array of data.
 
I want to create a CSV table from this, taking values from each object/array within the array and then save the completed CSV to a SharePoint site. 
 
To do this, I am starting with the following... is this correct? How can I, when the CSV is populated, save it to a SP site? If I go outside of the loop, how do I get the CSV data so that I can use the Create File (SharePoint) action?   If I put the action inside the loop, it'll create hundreds of files :( :(
 
 
Thank you
SD
  • Suggested answer
    David_MA Profile Picture
    10,858 Super User 2025 Season 1 on 26 Jul 2024 at 13:44:21
    Create CSV table from array
    There is an easier way to do what you want instead of what I posted below, but either method should work for your use case. You can also use a Select action followed by a Create CSV table action:
    I used the append to string variable method below because that solution is making a call to the graph API and can only return 999 rows at a time. If I tried the above method with that, I would end up with multiple CSV files.
     
  • Suggested answer
    David_MA Profile Picture
    10,858 Super User 2025 Season 1 on 26 Jul 2024 at 13:03:48
    Create CSV table from array
    I believe you want to pick certain values from each row in your array rather than create a csv file from the entire array, which is why you use the apply to each. If so, initialize a sting variable in your flow and set the default value to the comma-separated values you want for the header row. For example:
    The expression at the end adds a line break, which is important so that all the values are not on the same row. The expression to add the line break is:
    decodeUriComponent('%0A')
    Then in the apply to each, add a Append to string variable and populate it with the values you want. For example:
     
    Again, be sure to add the expression for a line break at the end. Then to create the file you would do the same as @rzaneti posted except you would replace Output with the string variable.
  • rzaneti Profile Picture
    4,024 Super User 2025 Season 1 on 26 Jul 2024 at 12:12:24
    Create CSV table from array
    Hi,
     
    You will need to make some small changes in your process. First, make sure that you are working with an array of objects (like in the Compose from the image below), as this is a requirement for  generating a CSV from this array. You can check these blog posts for more reference on the different Data Types in Power Automate and the Object Data Type in Power Automate
     
    As you want to generate a csv from an array, you won't need to loop it inside an Apply to each, but just pass the whole array as input to the Create CSV table action, like in the example below:
     
     
     
    By just doing that, you already have your CSV data, and now you just need to store it in a file. For that, you can use a Create file action, select the path where you want to save it, and pass the outputs from Create CSV table as "File content" (see the arrow below). For the "File name", make sure to include the extension .csv (highlighted in yellow):
     
     
    After running the flow, the CSV file is created in SharePoint:
     
    And it contains the same data from your array:
     
     
    Let me know if it works for you or if you need any additional help!
    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.
     

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

#1
stampcoin Profile Picture

stampcoin 97

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 72 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 48 Super User 2025 Season 1

Overall leaderboard
Loading started