I am new to python and posting to this forum and my searches turned up nothing. I am writing a component for a log parser to combine events from matching dates into one file. For some reason the log files split between 19:59:00 and 20:00:00 hours daily. To resolve this the code sample below reads the previous event count from a file based on the date being processed. Next the event number is incremented and added to each of the events and the merged lines are written to a file.
The problem I am having is some of the last events between 10 and 50 are either not written to the file or partially written. When using the interactive mode, while printing each line they are displayed correctly. I have tried using fileinput and read both produce the same results for each date. Using write instead of writelines also did not change the results.
Any suggestions are greatly appreciated.
Thanks in advance
Mece
Event Sample
FIREWALL-1 2008-10-02 20:00:04 Deny proto=17 192.168.10.90 123 172.15.6.5 123
last_count sample
2008-10-01 628756
count_file = open("/home/user/logs/last_count","r")
other_date = "2008-10-01"
for line in count_file.readlines():
if other_date in line:
line = line.split()
prev_event_count = line[1]
more_logs = file("/home/user/logs"+other_date+"-DENY.log-cont","w")
new_log_data = "/home/user/logs"+other_date+"-DENY.log-cont"
for line_data in open(data_file,"r"):
prev_event_count = int(prev_event_count) + 1
nudata = str(prev_event_count),str(line_data)
new_data = ' '.join(nudata)
more_logs.write(new_data)