Re: Parsing a log file

2005-08-14 Thread Andreas Kostyrka
Completly untested: #!/usr/bin/env python import sys, datetime user = sys.argv[1] starttime = None for l in sys.stdin: flds = l.strip().split() datestr, timestr, prog, op, to, sname = flds month, day, year = [int(x) for x in datestr.split("-", 2)] hour, min, sec, ms = [int(x) fo

Re: Parsing a log file

2005-08-14 Thread Andreas Kostyrka
Completly untested: #!/usr/bin/env python import sys, datetime user = sys.argv[1] starttime = None for l in sys.stdin: flds = l.strip().split() datestr, timestr, prog, op, to, sname = flds month, day, year = [int(x) for x in datestr.split("-", 2)] hour, min, sec, ms = [int(x) fo

Re: Parsing a log file

2005-08-14 Thread googleboy
I am similarly not a programmer but am trying to learn python to do tasks like this. I would read through the regular expressions tutorial. You could probably easily read in all teh lines of the log file, and then split them up by " " (spaces).. If you're right about the lines all being consis

Re: Parsing a log file

2005-08-14 Thread CG
John, Your comments are very helpful. I will take the datetime stamp as the way to go. I don't have a need to throw away the time info, it is You said: >What do you do if servers are in different >timezones? This is all inhouse in a non-daylight savings country and would not be an issue You a

Re: Parsing a log file

2005-08-14 Thread CG
Thanks Andreas, In your first paragraph, you ask about incorrect input. I guess it is possible, but without that information, my collection of the data is useless, so I really don't know what I would do with that. As for the other stuff, I can hack the data in other ways, such as with VBA and MS

Re: Parsing a log file

2005-08-14 Thread John Machin
CG wrote: [snip] > What I basically want to do is end up with a text file that can be > easily imported into a database with a format like this (or I guess it > could be written in a SQL script form that could write directly to a > database like Mysql): > > Connect_Date Connect_Time Disconnect_dat

Re: Parsing a log file

2005-08-14 Thread Andreas Kostyrka
Am Samstag, den 13.08.2005, 14:01 -0700 schrieb CG: Well, you have described your problem nicely. One thing that's missing is how to deal with incorrect input. (For example missing connect or disconnect messages). Furthermore, you can now: a) try to find somebody who writes it for you. How you mo

Parsing a log file

2005-08-13 Thread CG
I am looking for a way to parse a simple log file to get the information in a format that I can use. I would like to use python, but I am just beginning to learn how to use it. I am not a programmer, but have done some simple modifications and revisions of scripts. I am willing to attempt this o