Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Looping through Get File Content

(0) ShareShare
ReportReport
Posted on by 12

Hi,

 

I'm reading a text file through Get File content.  Is it possible to read each line and search for the keyword ERROR. ? 

PranavPh_0-1687880273683.png

 

I want to build a loop where it reads line by line and if it finds the keyword ERROR then will proceed further in IF condition. 

 

I tried using apply each but I'm going wrong somewhere! 

 

Eg. This sample file has 3 rows with ERROR keyword so the loop will enter the IF case 3 times where I can do other actions. 

 

@ekarim2020 @Expiscornovus 

Regards,

Pranav 

 

  • Verified answer
    Ellis Karim Profile Picture
    10,923 Super User 2025 Season 1 on at
    Re: Looping through Get File Content

    Just as an additional note, in some Windows text files each line could end with two characters: a Carriage Return (CR) and Line Feed (LF) characters:

    ekarim2020_1-1688078709159.png

    You can use apps such as NotePad++ to view these characters.

     

    So the file could also be split at the CRLF characters:

    split(body('Get_file_content'),decodeUriComponent('%0D%0A'))

     


    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

  • Verified answer
    Chriddle Profile Picture
    7,678 Super User 2025 Season 1 on at
    Re: Looping through Get File Content

    Yes, use this expression as the input of your Apply to each:

    split(output_of_your_file_content_action, decodeUriComponent('%0A'))

     

  • PranavPh Profile Picture
    12 on at
    Re: Looping through Get File Content

    Hey, should I use the Split in Apply to each loop? I'm very new to power platform so can you show an example? 

     

    Regards,

    Pranav 

  • Chriddle Profile Picture
    7,678 Super User 2025 Season 1 on at
    Re: Looping through Get File Content

    You can use function split() to split the file content at line breaks.

    https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#split

     

    Line break is decodeUriComponent('%0A')

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!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow