smsboodoo Posted October 16, 2009 Share Posted October 16, 2009 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 More sharing options...
Moderators Melba23 Posted October 16, 2009 Moderators Share Posted October 16, 2009 (edited) 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 October 16, 2009 by Melba23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 16, 2009 Share Posted October 16, 2009 (edited) 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 October 16, 2009 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 More sharing options...
smsboodoo Posted October 16, 2009 Author Share Posted October 16, 2009 (edited) 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 October 16, 2009 by smsboodoo Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 16, 2009 Share Posted October 16, 2009 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now