Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

How to convert a .txt file content to an array

(0) ShareShare
ReportReport
Posted on by 364

Hi All, 

 

Like the title says I am looking for help getting file content into an array format. When a file is added to a SharePoint folder, I want a flow to trigger and save the file data to Dataverse. Below is the content of the file:

Aurora_0-1707754662006.png

Date,12022024
Builder ID, 0046
Part Number, 171-CT1-1502
Serial Number,50015856499
,
,
Supplied Blower Voltage at 50% Duty,11.85791
Blower Current at 50% Duty,7.141113
Supplied Blower Voltage at 100% Duty,11.75293
Blower Current at 100% Duty,22.87598
,
Supplied Actuator Voltage at 0%,0
Actuator Current at 0%,9.998779
Supplied Actuator Voltage at 50%,5.908203
Actuator Current at 50%,6.055908
Supplied Actuator Voltage at 100%,11.87012
Actuator Current at 100%,2.645264
,
Ambient Temperature,73.98968
Core Temperature,65.53927
,
Core Nitrogen Pressure,36.20079
,
Leak Test, PASSED
Results: ,Test Passed

Aurora_1-1707756203757.png

^ the .csv file ^

 

I would like to break it down, so it has a format like: 

Date: 12022024
Builder ID: 0046
Part Number: 171-CT1-1502
Serial Number: 50015856499

 

No matter what I try, I am unable to get it out of the string format and into the array format. Does anyone have any suggestions for how I Can achieve this? I have attached my document as a .xlsx file, as power automate community does not support .csv. The file can be converted to .csv by saving it again.

 

Any support is greatly appreciated!

  • Verified answer
    ManishSolanki Profile Picture
    15,085 Super User 2025 Season 1 on at
    Re: How to convert a .txt file content to an array

    Hi @Aurora 

     

    Here is the sample flow.

     

    In this example, I have stored the csv content in a compose action using expression after getting content of the file:

    ManishSolanki_0-1707797599153.png

    Expression needs to be added in the expression box as highlighted in the above screenshot:

    base64ToString(body('Get_file_content')?['$content'])

     

    Next, add "Select" action to split the content in the array:

    ManishSolanki_1-1707797720026.png

    Expression used in 'From' parameter:

    split(outputs('Compose'),decodeUriComponent('%0D%0A'))

    Click 'Switch Map to text mode' button:

    ManishSolanki_2-1707797795179.png

    Enter below expression in the Map textbox:

    ManishSolanki_3-1707797869533.png

    replace(item(),',',':')

     

    Finally, add "Filter array" action remove the blank elements & elements containing only ':'. Pass the output of Select action in the "From" parameter:

    ManishSolanki_4-1707798007495.png

    Click 'Edit in advanced mode' button on the bottom and enter below query:

    @and(not(equals(item(), ':')),not(equals(item(), '')))

     

    The output of filter array action will give the desired array.

     

     

    Output:

    ManishSolanki_5-1707798106184.png

     

     

     

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

     

  • Aurora Profile Picture
    364 on at
    Re: How to convert a .txt file content to an array

    Edit: I put .txt file in the title, but this is for a .csv file. All my .csv files start out as .txt files, and then get converted .csv. If the flow could work for either file format, that would meet my needs.

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >