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 / Delete rows from csv file
Power Automate
Unanswered

Delete rows from csv file

(1) ShareShare
ReportReport
Posted on by 90

Hi everyone
I have a csv file located in SharePoint library. 

New rows are created in this file daily each time someone fills a Microsoft form.

I'm looking for a way to automatically delete the content of the CSV file daily every night so trigger would be Recurrence.

I can do it easily for Excel file with "Delete a row"  but it doesn't work for csv files.

Can anyone help?

Thanks

Categories:
I have the same question (0)
  • ManishSolanki Profile Picture
    15,091 Super User 2025 Season 2 on at

    Hi @Talko 

     

    One possible solution is, we could get the header row from the csv file and then update the file with the header row to clean it up. But this is only applicable if you have headers in the csv file.

     

    Here is the sample flow that cleans up all the data rows:

     

    1. Create a scheduled flow and set the recurrence as per your need like time zone, start time etc.:

    ManishSolanki_0-1699178657502.png

     

    2. Next, add "Get file content using path" action to read the content of the file in SharePoint library:

    ManishSolanki_2-1699178770805.png

    I have stored the csv file 'customers.csv' in 'STEW 2' document library, pls modify the path as per your need.

     

    3. Now, add compose action to fetch the header row from the file content. We need to write an expression to get the header row. Expression needs to be added in the expression box as highlighted in the below screenshot:

    ManishSolanki_3-1699178941169.png

    join(take(split(base64ToString(outputs('Get_file_content_using_path')?['body']?['$content']),decodeUriComponent('%0D%0A')),1),',')

     

    4. Finally, add "Update file" action to clean it up & set the output of compose action in "File content" parameter:

    ManishSolanki_4-1699179134653.png

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

  • Suggested answer
    jconnelly Profile Picture
    75 on at
    ManishSolanki's suggestion works, but leaves only the header column. Use the skip instead of the take command and it worked for me. Thanks Manish!

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