web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to convert a .txt ...
Power Automate
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!

Categories:
I have the same question (0)
  • Aurora Profile Picture
    364 on at

    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.

  • Verified answer
    Manish Solanki Profile Picture
    15,169 Moderator on at

    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.

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 959

#2
Valantis Profile Picture

Valantis 872

#3
Haque Profile Picture

Haque 589

Last 30 days Overall leaderboard