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 / Remove first 3 rows fr...
Power Automate
Unanswered

Remove first 3 rows from a txt

(0) ShareShare
ReportReport
Posted on by 13

Hello!
I have a txt file sent by email, I want to delete/skip the first 3 rows/lines:

 

rogerlopez21_0-1708162705809.png

 

I want to keep the headers:

rogerlopez21_1-1708162775904.png

 

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

    Hi @rogerlopez21 

     

    Here is the sample flow.

     

    1. Create an automated flow & choose "When a new email arrives" as the trigger. You could apply filter on sender, to, cc, subject etc. based on the need. Here I have applied filter on subject for demo purpose:

    ManishSolanki_0-1708172874982.png

     

    2. Next, add "Get attachment" action to get the content of the email attachment. Pass message id and attachment id dynamically from the previous action. The action will be automatically wrapped inside 'Apply to each' after passing the input parameters:

    ManishSolanki_1-1708173158946.png

     

    Finally, inside Apply to each block add compose action to get the final text with first 3 lines skipped. We will use expression to skip the first 3 lines. Expression needs to be added in the expression box as shown below:

    ManishSolanki_2-1708173312224.png

    join(skip(split(base64ToString(outputs('Get_Attachment_(V2)')?['body/contentBytes']),decodeUriComponent('%0D%0A')),3),decodeUriComponent('%0D%0A'))

    The output of compose action will give the required text. You can create a new file by passing the output of compose action or share it in the email.

     

     

    Input text file:

    ManishSolanki_3-1708173420468.png

     

     

    Output of compose action:

    ManishSolanki_4-1708173471558.png

     

     

     

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

     

  • Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at

    Hi @rogerlopez21 ,

     

    It seems like that the file is a csv text file. You could try the following:

    Snag_372492c.png

    The Apply to each loop is used to handle 1 or more text file attachments:

    Snag_39161ed.png

     

    The Compose actions transform the file in steps:

    Snag_3894eaa.png

    Snag_38ab3f7.png

    Snag_38c1d4b.png

    Snag_38cf07a.png

    Here are the expressions used in the Compose actions:

     

    Compose:
    base64ToString(item()?['contentBytes'])
    
    Compose: 2:
    split(outputs('Compose'),decodeUriComponent('%0D%0A'))
    
    Compose 3:
    skip(outputs('Compose_2'),3)
    
    Compose 4:
    join(outputs('Compose_3'), decodeUriComponent('%0D%0A'))

     

    Finally create the new file:

    Snag_36f8b93.png

    You could later merge the all the expressions into a single expression and use that as the File Content in the Create File action:

     

    join(skip(split(base64ToString(item()?['contentBytes']), decodeUriComponent('%0D%0A')),3),decodeUriComponent('%0D%0A'))

     

    See also: Solved: Re: Looping through Get File Content - Power Platform Community (microsoft.com)
    Ellis
    ____________________________________
    If I have answered your question, please mark the post as ☑️ Solved.
    If you like my response, please give it a Thumbs Up.
    My Blog Site

  • rogerlopez21 Profile Picture
    13 on at

    It worked, thanks you for your feedback!

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard