[Tutor] Iterable Understanding

Stephen Nelson-Smith sanelson at gmail.com
Sun Nov 15 12:42:24 CET 2009


Hi Martin,

Thanks for a very detailed response.  I'm about to head out, so I
can't put your ideas into practice yet, or get down to studying for a
while.

However, I had one thing I felt I should respond to.

> It's unclear from your previous posts (to me at least) -- are the
> individual log files already sorted, in chronological order?

Sorry if I didn't make this clear.  No they're not.  They are *nearly*
sorted - ie they're out by a few seconds, every so often, but they are
in order at the level of minutes, or even in the order of a few
seconds.

It was precisely because of this that I decided, following Alan's
advice, to pre-filter the data.  I compiled a unix sort command to do
this, and had a solution I was happy with, based on Kent's iterator
example, fed into heapq.merge.

However, I've since discovered that the unix sort isn't reliable on
the last and first day of the month.  So, I decided I'd need to sort
each logfile first.  The code at the start of *this* thread does this
- it uses a heapq per logfile and is able to produce a tuple of
timestamp, logline, which will be in exact chronological order.  What
I want to do is merge this output into a file.

I think I probably have enough to be getting on with, but I'll be sure
to return if I still have questions after studying the links you
provided, and trying the various suggestions people have made.

Thanks so very much!

S.


More information about the Tutor mailing list