Yuushi Posted February 3, 2009 Share Posted February 3, 2009 (edited) I got a log file with a few lines in there that I dont really need for my results so I want to get rid of those unwanted lines. I found a way to read and write lines but not delete. Now I could read the line match them with what I dont want and dont write those lines to a new file but somehow I think there is a easier way? Is there anyone who can help me along with this idea? Logfile looks a bit like: [12:05:41] [12:05] Tanvu: Inspiration from Beyond (10) (Not Modified) [12:05:41] [12:05] Tanvu: Civic Improvement (9) (Event Threshold: 40) [12:05:41] [12:05] Tanvu: Whistle While You Work (9) (Event Threshold: 40) [12:05:41] [12:05] Tanvu: Tricks of the Trade (9) (Event Threshold: 40) [12:05:41] [12:05] Tanvu: Shared Effort (11) (Event Threshold: 40) [12:05:41] [12:05] You lose 20 silver. [12:05:52] [12:05] Leth Nurae: Call to Arms (10) (Not Modified) [12:05:52] [12:05] Leth Nurae: Raise Morale (10) (Not Modified) [12:05:52] [12:05] Leth Nurae: Prepare for Battle (10) (Not Modified) [12:05:52] [12:05] Leth Nurae: Increase the Watch (10) (Not Modified) [12:05:52] [12:05] Leth Nurae: Civic Improvement (10) (Not Modified) [12:05:52] [12:05] Leth Nurae: Whistle While You Wor Idea is to get rid of the lines saying something like You lose and keep the others to extract information from them Regards, Yuushi Edited February 3, 2009 by Yuushi Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 3, 2009 Share Posted February 3, 2009 I got a log file with a few lines in there that I dont really need for my results so I want to get rid of those unwanted lines. I found a way to read and write lines but not delete.Now I could read the line match them with what I dont want and dont write those lines to a new file but somehow I think there is a easier way? Is there anyone who can help me along with this idea?Idea is to get rid of the lines saying something like You lose and keep the others to extract information from themRegards,YuushiFrom the help file under _FileWriteToLine(): RemarksIf _FileWriteToLine is called with $fOverWrite as 1 and $sText as "", it will delete the line. 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...
NerdFencer Posted February 3, 2009 Share Posted February 3, 2009 (edited) 1-read the file to a variable 2-use StringSplit to break the file into lines (separate variable) 3-set the original variable that stores the file to "" 4-loop through the lines and detect which ones you dont want, exclude these lines from next step 5-append the lines back to the variable containing the file contents 6-write the contents back to the file (overwriting previous contents) Done Edit: was writing while PsaltyDS was, his solution is better Edited February 3, 2009 by NerdFencer _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell 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