I have a task that sounds simple enough... but I don't code in Python; my background is in network design. So, here we go, I have to write a script that scans text files on a network share to parse for anything in the the text log that begins with "ERROR". Each error needs to be broken down by type, (cumulative) count, over a 24/hour history. It need not be node specific because all nodes will have all errors, but not necessarily at the same time, or same count. Again, I only want a cumulative count listed next to each error type. My programming experience is limited to "hello world" readouts. Im using Python 3.1 gui, but I can't seem to find the syntax that suits my needs. Any help would be appreciated.

Recommended Answers

All 2 Replies

An example of a portion of a typical error text file would help muchly!

Ok.. I think Im making headway. here's what I have now

f = open('/my/network/share/file.txt', 'r')
lines = f.readlines()

for line in lines:
print line,]

My next step will be to parse the file for all lines that begin with "ERROR:". After that, I need to consolidate like-errors and give a total of each. Since the files I'm parsing have no delimiting character, I'm not sure how to go about that. Do I use the date/time stamp for the next entry since its yyyyMMdd format?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.