Skip to main content

Notifications

Community site session details
Power Automate - General Discussion
Answered

Unable to merge two csv files using Powerautomate flows

Like (0) ShareShare
ReportReport
Posted on 12 Sep 2022 09:58:21 by 5

Hi All,

 

The requirement is to send a combined csv file as an attachment with common field/columns from two different entities. Using List rows action & create csv table, I am able to achieve two csv files for each. 

I want to merge and send the combined csv files as a single attachment.

 

Any help is much appreciated.

 

Regards,

Hemanth DR

  • Rishicfdi Profile Picture
    12 on 16 Sep 2023 at 12:02:48
    Re: Unable to merge two csv files using Powerautomate flows

    This is a very efficient solution. 

    However, I am trying to merge multiple (undecided, depending on Dataverse Table size) Create CSV table actions based on a loop. Any ideas to keep concatenating result of the latest one to the previously concatenated ones?
    I saw the advise for three files, however I will have anywhere between 3- 7 Create a CSV actions out of which one will be preliminary and others in a Do until loop. (I am using Skip Token to list rows dataverse table)

    Thanks

  • srduval Profile Picture
    1,663 Super User 2025 Season 1 on 16 Mar 2023 at 12:29:28
    Re: Unable to merge two csv files using Powerautomate flows

    repeat his steps for the second compose, (skiping file header etc), then either do a concat(concat( or setup an additional compose and do concat(outputoffirstconcat,third file contents)

  • GregHM Profile Picture
    2 on 15 Mar 2023 at 16:31:54
    Re: Unable to merge two csv files using Powerautomate flows

    Hi @Paulie78 , this is a brilliant solution, how would you then concat a 3rd table to the results of the first 2? I have tried unsuccessfully so far

  • Rana1 Profile Picture
    21 on 23 Feb 2023 at 23:04:35
    Re: Unable to merge two csv files using Powerautomate flows

    Thanks @Paulie78 , Saved my day . Exactly what I was looking for. Wanted to append one Create CSV output to another and your solution worked like a charm.

  • navathad Profile Picture
    2 on 24 Oct 2022 at 05:29:55
    Re: Unable to merge two csv files using Powerautomate flows

    Hi There, Please help me with any ideas here, can this be implemented with Export To File from Paginated Reports in Power Automate(Other than using Power Automate Desktop to create flow and then scheudling in Power Automate);  I'm trying to merge 2 CSV Files( as it gives error for file size limitation to Create File to get the whole data in a single file). Also, Append overwrites the data in the file. Any suggestions would be helpful. Thank you.

    navathad_0-1666589091022.png

     

    navathad_1-1666589190286.png

     

  • HemanthDR Profile Picture
    5 on 12 Sep 2022 at 13:02:27
    Re: Unable to merge two csv files using Powerautomate flows

    Thank You @Paulie78 , I am now able to Merge two CSV files.

     

    Thanks @srduval .

  • Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on 12 Sep 2022 at 11:53:18
    Re: Unable to merge two csv files using Powerautomate flows

    It is difficult to be sure. But I read the original post to mean that he is already able to successfully generate two CSV files. He just wants them to be a single CSV file. Perhaps the original poster will clarify.

  • srduval Profile Picture
    1,663 Super User 2025 Season 1 on 12 Sep 2022 at 11:50:12
    Re: Unable to merge two csv files using Powerautomate flows

    I believe the intent is to merge AKA join the two tables, not union them

  • Verified answer
    Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on 12 Sep 2022 at 11:37:05
    Re: Unable to merge two csv files using Powerautomate flows

    It is quite easy to do. The main complication is that the "Create CSV Table" action helpfully includes a header row. If you join the output of two of these actions you will have a extra header row where the second CSV file begins. So I would do something like this:

    CombineCSV.png

    First, the two separate CSV files are created.

     

    Then there is a compose action which splits the output of the second CSV on a line break to turn it into an array. The first element of that array is skipped and then the array is turned back into a string but without the header row. The expression used for this is:

    join(skip(split(body('Create_CSV_table_2'), decodeUriComponent('%0A')), 1), decodeUriComponent('%0A'))

     

    Then the two string outputs of the original CSV and the RemoveHeaderFromCSV2 actions are combined in a final compose action with the expression:

    concat(body('Create_CSV_table'),outputs('RemoveHeaderFromCSV2'))

     

    Blog: tachytelic.net

    YouTube: https://www.youtube.com/c/PaulieM/videos

    If I answered your question, please accept it as a solution 😘

     

  • srduval Profile Picture
    1,663 Super User 2025 Season 1 on 12 Sep 2022 at 11:19:19
    Re: Unable to merge two csv files using Powerautomate flows

    Check out this post. I think what you're after is trying to merge two arrays (list rows) and include the values from one file where a key column matches the other file:

    Solved: Re: how to merge two arrays - Power Platform Community (microsoft.com)

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

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,079 Most Valuable Professional

Leaderboard