Jump to content

Removing text from a File


Recommended Posts

I have a text file that contains two sets of information. Within the file there is a header and trailer records for each set of data. The length of each section could be variable. I need to be able to split each section into their own files, thus creating two files from one. Each complete with their own header and trailer. I also need to maintain the existing format.

What I was thinking of doing is making a copy of the file and then removing the unwanted text from each of the two file. The other option is to read the contents of the file and write the first or last section to another file. In either case, I need to be able to identify where the two sections start and stop.

Has anyone done something like this already and can get me going in the right direction? I appreciate any help you may have.

Link to comment
Share on other sites

  • Moderators

smsboodoo,

Can you please give us an idea of what the "header and trailer records" look like? It is a bit difficult to offer advice without a sample of the thing to look at! :)

M23

Edit: Speeling!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I have a text file that contains two sets of information. Within the file there is a header and trailer records for each set of data. The length of each section could be variable. I need to be able to split each section into their own files, thus creating two files from one. Each complete with their own header and trailer. I also need to maintain the existing format.

What I was thinking of doing is making a copy of the file and then removing the unwanted text from each of the two file. The other option is to read the contents of the file and write the first or last section to another file. In either case, I need to be able to identify where the two sections start and stop.

Has anyone done something like this already and can get me going in the right direction? I appreciate any help you may have.

All you need is a nested loop. The outer loop reads the file one line at time and when a new header is found creates a new output file and starts the inner loop. The inner loop outputs to the new file until the trailer is seen, then it closes the output file and exits back to the outer loop.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I have a text file that contains two sets of information. Within the file there is a header and trailer records for each set of data. The length of each section could be variable. I need to be able to split each section into their own files, thus creating two files from one. Each complete with their own header and trailer. I also need to maintain the existing format.

What I was thinking of doing is making a copy of the file and then removing the unwanted text from each of the two file. The other option is to read the contents of the file and write the first or last section to another file. In either case, I need to be able to identify where the two sections start and stop.

Has anyone done something like this already and can get me going in the right direction? I appreciate any help you may have.

Attached Sample File.

Edited by smsboodoo
Link to comment
Share on other sites

Attached Sample File.

No, you didn't. :)

But it isn't required anyway. Are you just looking for someone to write it for you? Go to the Rent-A-Coder link in my sig. We don't do that here.

If you want to learn how to do it yourself, start coding and just post the code you need help with.

You can do it!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...