954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Python Basic Script

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.

elt6801
Newbie Poster
2 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

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

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

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

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

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?

elt6801
Newbie Poster
2 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: