Skip to main content

Notifications

Community site session details

Community site session details

Session Id : cCv2r6NDbdwSNuGzBt340j
Power Automate - Building Flows
Answered

Combine CSV Files in SharePoint Folder Into One Master File

Like (0) ShareShare
ReportReport
Posted on 24 Jan 2022 13:14:25 by 102

All, 

 

I have a flow that exports data to our SharePoint Site (documents). The flow also creates a folder based on current Date and uses Employee ID to name the file. 

 

 

So Inside our SharePoint Site we will have multiple folders and files:

 

Share Point URL (example)https://test.sharepoint.com/sites/test/

 

Folder and File (example):

/Timesheet/TimesheetTest/01-24-2022/Employee101.cvs

/Timesheet/TimesheetTest/01-25-2022/Employee102.cvs

/Timesheet/TimesheetTest/02-24-2022/Employee103.cvs

 

 

Now I would like to create a new flow and combine all these files into one master Excel file.

 

 

 

All files have the same column's and none of these files are in table format. 

Is this possible? 

 

aishak12_0-1643030018899.png

aishak12_1-1643030054953.png

 

 

 

 

 

 

 

 

 

 

 

 

Employee101.xls 

  • roger4 Profile Picture
    2 on 06 Feb 2024 at 16:17:57
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    Hi - I've copied this solution to merge 2 CSV files into a new output file, but the header - first row -  from the second still writes to the new file  - I'm using the expressions shown here - 

    base64ToString(outputs('Get_file_content')?['body']['$content'])
    skip(base64ToString(outputs('Get_file_content_2')?['body']['$content']),add(indexOf(base64ToString(outputs('Get_file_content_2')?['body']['$content']),variables('Enter')),1))

     all else exactly the same - any ideas?

  • minyoungchoe Profile Picture
    112 on 08 Nov 2023 at 18:32:03
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    How did you use the loop to pick up all files?

  • minyoungchoe Profile Picture
    112 on 08 Nov 2023 at 18:29:49
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    Can you help me?...
    I am stuck to bring all csv files using get files

  • vr_2020 Profile Picture
    2 on 14 Sep 2023 at 12:27:05
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    @v-bofeng-msft - Hi, I have similar requirement and try to combine/append 4 csv files (File1.csv, File2.csv, File3.csv, File4.csv)  in Sharepoint folder ( eg: /Shared Documents/General/CSVFiles) and create a master file in same sharepoint folder path. I understand that there should be 4 Get file content action to be created for each csv files. However, I am not quite sure as in what should be given in "File Identifier" field. Should that be ID as File Identifier from Dynamic content? Could you please help me with these details?

  • JorgeRocha Profile Picture
    3 on 15 Mar 2023 at 14:52:50
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    If you only have one sheet, and you know the total of lines, you can create a table on top of your file and them push the data into a string and put it into a csv file.

     

    Source: https://www.youtube.com/watch?v=nGTRuqcpUM0

     

    After that you combine the CSVs in a different flow (or the same flow, later)

  • SRCoding Profile Picture
    3 on 24 Jan 2023 at 23:12:59
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    After being stuck trying to find a solution that doesn't require any of the "API Services", this was the solution!
    Thank you very much!

     

    Note that both files need to be .csv otherwise when you try to convert to base64, the data will be corrupted. I didn't figure out a solution to merge .xlsx and .csv unfortunately.

  • nix_99 Profile Picture
    3 on 06 Sep 2022 at 12:58:11
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    This is brilliant @v-bofeng-msft  - thank you!  Is there a way to add a column with the original file name?

  • ravitej465 Profile Picture
    16 on 01 Apr 2022 at 06:03:55
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    Hi @v-bofeng-msft ,

    Thank you for the above solution.

    I have a similar requirement but which needs to be an automatic flow.

     

    Have folder 1,2,3,4,5 in a SharePoint and Excel files will get added with same header names and same number of columns with different data.

     

    Requirement is to create a master file when a new gets added to any folder in the SharePoint..

     

    Could you please provide a solution to implement this?

  • v-bofeng-msft Profile Picture
    on 02 Feb 2022 at 01:22:27
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    Hi @aishak12 :

    In the solution I provided at the beginning there is a way to skip the first line

    vbofengmsft_0-1643764870661.png

    Best Regards,

    Bof

  • aishak12 Profile Picture
    102 on 28 Jan 2022 at 21:52:59
    Re: Combine CSV Files in SharePoint Folder Into One Master File

    Ok so this is my current flow and it is now working perfectly picking up all files and combining them. 

    But How do I skip the header (1st) row of all the files. 

    aishak12_1-1643406667557.png

     

     

     

    s

     

     

    ok

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 55

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 39 Super User 2025 Season 1

#3
VictorIvanidze Profile Picture

VictorIvanidze 26

Overall leaderboard