Having a problem with parsing Snort logs using the pyparsing module.
The problem is with separating the Snort log (which has multiline entries, separated by a blank line
Well, I don't know Snort or pyparsing
, so apologies in advance if I say something stupid. I'm unclear as to whether the problem is with pyparsing
being unable to handle the entries, or with you being unable to send them to pyparsing
in the right format. If the latter, why not do something like this?
def logreader( path_to_file ):
chunk = [ ]
with open( path_to_file ) as theFile:
for line in theFile:
if line:
chunk.append( line )
continue
else:
yield "".join( *chunk )
chunk = [ ]
Of course, if you need to modify each chunk before sending it to pyparsing
, you can do so before yield
ing it.