Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.033 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'column': 0.07; 'subject:report': 0.09; 'subject:string': 0.09; 'timestamp': 0.09; 'cc:addr:python-list': 0.10; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message- id:@tim.thechases.com': 0.16; 'started?': 0.16; 'status.': 0.16; 'subject:log': 0.16; 'string': 0.17; 'wrote:': 0.17; 'specify': 0.17; 'examples': 0.18; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'subject:/': 0.28; "skip:' 10": 0.30; '(from': 0.30; 'file': 0.32; '(2)': 0.32; 'instances': 0.33; 'anyone': 0.33; '(1)': 0.34; 'filter': 0.35; 'something': 0.35; 'far': 0.37; 'subject:: ': 0.38; 'where': 0.40; 'further': 0.61; 'is.': 0.62; 'provide': 0.62; 'details': 0.63; 'email addr:gmail.com': 0.63; 'total': 0.65; 'hour': 0.69; 'day': 0.73; '4th': 0.78; 'hour,': 0.84; 'presumably': 0.84; 'received:50.22': 0.84; 'subject:Search': 0.84; 'received:108': 0.91 Date: Wed, 23 Jan 2013 14:08:19 -0600 From: Tim Chase User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: spek06@gmail.com Subject: Re: Search log for string and display hourly/daily report References: <4f952e77-258d-47ae-9d76-a86daa8acaa2@googlegroups.com> In-Reply-To: <4f952e77-258d-47ae-9d76-a86daa8acaa2@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358971622 news.xs4all.nl 6931 [2001:888:2000:d::a6]:60886 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37500 On 01/23/13 13:05, spek06@gmail.com wrote: > I need to search a log file for a specific string (Successfully > Sent) and report the number of instances in the last hour (from > when executed) and total for the day so far (midnight till the > time executed). Can anyone provide any examples of such a program > or get me started? You'd have to specify additional details on how the log-file is formatted, presumably how it's delimited, and what the format of the corresponding time-stamp is. Something like "I have a tab-delimited log file where the 4th column is the timestamp in the format 'YYYY-MM-DD HH:mm:ss' and the 18th column is the status. I want to search for items where the status contains 'Successfully Sent' and then further filter them by (1) events in the last hour, and (2) all events today" -tkc