cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
aishak12
Helper IV
Helper IV

Combine CSV Files in SharePoint Folder Into One Master File

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 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

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

 

 

 

 

 

 

View solution in original post

13 REPLIES 13
v-bofeng-msft
Community Support
Community Support

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

 

 

 

 

 

 

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

Hi @aishak12 :

Yes.

Best Regards,

Bof

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

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

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?

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

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.

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)

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

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

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

roger4
Regular Visitor

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?

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (2,681)