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 / Help Creating a Flow t...
Power Automate
Unanswered

Help Creating a Flow to extract text from dynamic txt. attachments and putting into Excel

(2) ShareShare
ReportReport
Posted on by 7
Hello,
 

I'm trying to build a flow that reads a .txt file from an email attachment and writes data to Excel. I need to extract the Job Number, part numbers, and quantities.

 

The file looks like this:

 
 
>>> PART CHANGES FOR 133556-94->Refrigerant Leak Detection Panel <<<
-2    102059        DANFOSS,MOD COMM AK2-CM101C,LON485    BSCP.Elec part
-6    106286        TIME DELAY,208V,SPDT,ON DELAY    BSCP.Elec part
1    11140-2    QOU215    CIR BRK,15A,240V,2P,SM    BSCP.Elec part
-1    86009    SKMPL-4C-240VAC    RELAY,240VAC,14 PIN,SKMPL4C240VAC    BSCP.Elec part
-2    92104    080Z0007    DANFOSS,MOD AK2-XM101A 8AI    BSCP.Elec part
1    93618    1322580CH    BLOCK,PWR DISTR,175A,600V,2POLE    BSCP.Elec part
-30    93868    BQ1B010L    CIR BRK,10A,240V,1P,SM    BSCP.Elec part
-1    96656    080Z0055    DANFOSS,MOD  I/O PWR SUPPLY 60VA,IOPS    BSCP.Elec part
-1    99775    PH250MGJ    TRANS,1P,250VA,380/277/208PR-120/240SE    BSCP.Elec part

 *************************************** 

The Job Number is always in the first line after "Part Changes for".

The subsequent lines contain quantity and part number, separated by a tab.
 

So far, I'm stuck getting the flow to parse this correctly and populate Excel. Any tips on how to structure the Compose expressions or parsing logic?

 

Thanks in advance!

 
Categories:
I have the same question (0)
  • VictorIvanidze Profile Picture
    13,073 on at
    Share your flow.
  • rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at
     
    A few questions:
    - After the job number, will you always have a "->" ?
    - Are the dashes before some of the quantities a minus sign, or it must be ignored?
    - You have a few blanks between the quantities and the  part numbers, and between the part numbers and the next property. Will your data always follow this pattern?
     
  • CU11050407-0 Profile Picture
    7 on at
    A few questions:
    - After the job number, will you always have a "->" ? (Yes)
    - Are the dashes before some of the quantities a minus sign, or it must be ignored? (those are minus signs and should be included, as they denote a subtraction of the parts in that row)
    - You have a few blanks between the quantities and the  part numbers, and between the part numbers and the next property. Will your data always follow this pattern? (yes, the data will always follow this pattern)
  • CU15051710-0 Profile Picture
    2 on at
  • Suggested answer
    rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at
     
    Thank you for your answers. I stored your sample data into this Compose:
     
     
    Then used this expression to get the Job Number: first(split(last(split(outputs('Compose_-_Source'), 'CHANGES FOR')), '->'))
     
    Next, used a Filter array to remove the top column and the bottom ones. I'm using a split to transform the text into an array, where each line corresponds to an record, and then a to ignore the first line. In the filter query itself, we're removing any empty lines, or those which contain many *******:
     
     
    From expression: skip(split(outputs('Compose_-_Source'), decodeUriComponent('%0A')), 1)
    Filter Query expression (make sure to change it to Edit in advanced mode before adding): and(not(empty(trim(item()))), not(contains(item(), '******')))
     
    Finally, in the Select we're transforming the array of lines into an array of objects, containing the Part number and the Qty for each record. In both cases, we're working with a split function passing 4 blank spaces (or a tab) as separator, and then accessing the respective element. For the Qty, we're also transforming it in an integer number (if you prefer to keep it as text, just remove the int function from there): 
     
    Part number expression: split(item(), '    ')[1]
    Qty expression: int(split(item(), '    ')[0])
     
     
    Outputs
    Job number
     
     
    Parts and qtys
     
     
     
     
    Let me know if it works for you or if you need any additional help!
     
    If this solved your issue, please mark it as Accepted Answer.
    👍 If it helped, feel free to give it a like!

    🌐 Explore more Power Platform content on my Website or on my ▶️ YouTube
    💼 Find me on LinkedIn
     
     

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