Jump to content
Sign in to follow this  
BOBBY328

Parsing a Log File

Recommended Posts

BOBBY328

Can someone please help me in parsing a log file for activity within a certain date and appending that activity into a new log file ? Following is a sample of the data in the log file:

11/22/07 03:05:09

FAST TRACK 2+2 DOWNLOAD PROGRAM, PORT 1

Logged on to FAST TRACK 2+2, 1 trys

Reading EPROM version number

EPROM version is RS255 04/10/01

Set FT 2+2 Tech code

Reading Time and Date from FT 2+2

Reading Configuration Data from FT 2+2

First day of week is WED

Single Lane Ft 2+2

Loading Store Data from FT 2+2

FT 2+2 Event Logger Not Full

Loading Event Data from FT 2+2

Printing 'Event Log Read' on FT 2+2

Loading A Side Current Data from FT 2+2

Loading A Side Archive Data from FT 2+2

FAST TRACK 2+2 LOGGED OFF

COMPLETED SUCCESSFULLY

11/22/07 03:06:37

I need to capture the 2 Date/time lines plus the info between those 2 date lines and put that into a new log file. I've tried everything but can't get it. Attached is some of the garbage I have tried:

Any help would be greatly appreciated.

FileParse3.au3

Share this post


Link to post
Share on other sites
picaxe

Just to get you started, try something like this in your main loop.

$flag = 0
$log = ""
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    If $line = "" Then ContinueLoop
    If StringRegExp($line, "[0-1][0-9][//][0-9][0-9][//][0-9][0-9][ ][0-2][0-9][:][0-5][0-9][:][0-5][0-9]") Then $flag += 1
    Switch $flag
        Case 1
            $flag = 1
            $log &= $line & @CRLF
        Case 2
            $flag = 0
            $log &= $line & @CRLF
    EndSwitch
WEnd
MsgBox(0, "", $log)

Share this post


Link to post
Share on other sites
Valuater

Just to get you started, try something like this in your main loop.

$flag = 0
$log = ""
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    If $line = "" Then ContinueLoop
    If StringRegExp($line, "[0-1][0-9][//][0-9][0-9][//][0-9][0-9][ ][0-2][0-9][:][0-5][0-9][:][0-5][0-9]") Then $flag += 1
    Switch $flag
        Case 1
            $flag = 1
            $log &= $line & @CRLF
        Case 2
            $flag = 0
            $log &= $line & @CRLF
    EndSwitch
WEnd
MsgBox(0, "", $log)
That just doesn't look right

8)


NEWHeader1.png

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  

×