Re: Parsing a potentially corrupted file

2016-12-14 Thread Paul Rubin
Paul Moore writes: > I'm looking for a reasonably "clean" way to parse a log file that > potentially has incomplete records in it. Basically trial and error. Code something reasonable, run your program til it crashes on a record that it doesn't know what to do with, add code to deal with that,

Re: Parsing a potentially corrupted file

2016-12-14 Thread MRAB
On 2016-12-14 11:43, Paul Moore wrote: I'm looking for a reasonably "clean" way to parse a log file that potentially has incomplete records in it. The basic structure of the file is a set of multi-line records. Each record starts with a series of fields delimited by [...] (the first of which i

Re: Parsing a potentially corrupted file

2016-12-14 Thread Paul Moore
On Wednesday, 14 December 2016 12:57:23 UTC, Chris Angelico wrote: > Is the "[Component]" section something you could verify? (That is - is > there a known list of components?) If so, I would include that as a > secondary check. Ditto anything else you can check (I'm guessing the > [level] is one

Re: Parsing a potentially corrupted file

2016-12-14 Thread alister
On Wed, 14 Dec 2016 03:43:44 -0800, Paul Moore wrote: > I'm looking for a reasonably "clean" way to parse a log file that > potentially has incomplete records in it. > > The basic structure of the file is a set of multi-line records. Each > record starts with a series of fields delimited by [...

Re: Parsing a potentially corrupted file

2016-12-14 Thread Chris Angelico
On Wed, Dec 14, 2016 at 10:43 PM, Paul Moore wrote: > This is a messy format to parse, but it's manageable. However, there's a > catch. Because the logging software involved is broken, I can occasionally > get a log record prematurely terminated with a new record starting > mid-stream. So some