cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kenthub
Frequent Visitor

Delete First Line of Text in txt file

Hi all,

 

I have a .txt file that contains header information. I would like to remove that information, save the file/create a new file, and put it in a different folder.

 

I'm not sure how to remove the first line. Here are the steps i am trying:

  1. If the list exists
    1. Read the file contents
    2. Create a list
    3. Add the file contents to the list
    4. ** remove the first row somehow**
    5. ** write the remainder of the list to a new txt file**
    6. save that file to the appropriate location.

I need help on steps 4 and 5. Not sure  how to remove/delete List[0] and then create a new file.

4 REPLIES 4
MichaelAnnis
Super User
Super User

Edit:  After deleting the row, use PAD Save As Excel to pick your path, filename, and extension (.xlsx .csv .txt, etc.)

 

Use send keys to navigate through Excel to delete the row and resave the file:

 

MichaelAnnis_0-1642526737793.png

Those 2 are red because I don't have a filepath or filename variable.

 

Be sure to set the time between keystrokes on the 'Send Keys {Alt}()fao' to 100, as the Excel menu is just a little slower on hot keys.  You could set all the send keys to 100 if you want to just give it more time all around.

 

So, walking through it:  Make sure the window is the focused window before you start

  • Control + Home will go to A1
  • Control + Minus will try to delete, but should bring up an ask box for cell or row
  • Alt + r selects entire row
  • Enter clicks ok

Edit:  Then use PAD to Save As the Excel File.

 

  • Alt f a o (notice alt is not held down, that is why fao is outside the parenthesis) is File -> Save As -> Browse
  • Wait for the File Name text field element
  • FilePath and Enter will take the browse to the folder you want
  • Wait 1
  • FileName and Enter will save the file

Good luck!

PAG
Resolver I
Resolver I

Hello @kenthub ,

Maybe this will work?

https://power.automate.gallery/UevrYxqoZEbt 

Jeeeezzz

No chance of a terrorist attack with PDA is there ? 😂

I would record a Macro, just delete the first row surely.

I just find sending keys can be flaky, rarely I know but it does happen.

Thanks for this. I just opened the file in excel, removed the first row, and closed and saved it where I wanted. 

 

Luckily the file formatted well coming across! 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (1,885)