Jump to content
Sign in to follow this  
Yuushi

DeleteLine in openfile

Recommended Posts

Yuushi

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 by Yuushi

Share this post


Link to post
Share on other sites
PsaltyDS

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 them

Regards,

Yuushi

From the help file under _FileWriteToLine():

Remarks

If _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

Share this post


Link to post
Share on other sites
NerdFencer

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 by NerdFencer

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.