web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Combine CSV Files in S...
Power Automate
Unanswered

Combine CSV Files in SharePoint Folder Into One Master File

(0) ShareShare
ReportReport
Posted on by 104

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 

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @aishak12 :

    I've made a test for your reference:

    vbofengmsft_0-1643249703816.png

    vbofengmsft_1-1643249711429.png

    vbofengmsft_2-1643249720134.png

    vbofengmsft_3-1643249731641.png

    My flow:

    vbofengmsft_6-1643250336939.png

    Expression for your reference:

    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))
    skip(base64ToString(outputs('Get_file_content_3')?['body']['$content']),add(indexOf(base64ToString(outputs('Get_file_content_3')?['body']['$content']),variables('Enter')),1))

     

    The Result:

    vbofengmsft_5-1643250281769.png

    Best Regards,

    Bof

     

     

     

     

     

     

  • aishak12 Profile Picture
    104 on at

    Thank you, What if the folder has more than 3 files. Can I loop to pick up all files in the folder? 

  • v-bofeng-msft Profile Picture
    on at

    Hi @aishak12 :

    Yes.

    Best Regards,

    Bof

  • aishak12 Profile Picture
    104 on at

    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

  • v-bofeng-msft Profile Picture
    on at

    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

  • ravitej465 Profile Picture
    16 on at

    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?

  • nix_99 Profile Picture
    3 on at

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

  • SRCoding Profile Picture
    3 on at

    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.

  • JorgeRocha Profile Picture
    3 on at

    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)

  • vr_2020 Profile Picture
    2 on at

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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard