Pyparsing CSV string with random quotes

Posted by gtfx on Stack Overflow See other posts from Stack Overflow or by gtfx
Published on 2010-05-09T12:48:54Z Indexed on 2010/05/09 12:58 UTC
Read the original article Hit count: 296

Filed under:
|
|
|

Hey,

I have a string like the following:

<118>date=2010-05-09,time=16:41:27,device_id=FE-2KA3F09000049,log_id=0400147717,log_part=00,type=statistics,subtype=n/a,pri=information,session_id=o49CedRc021772,from="[email protected]",mailer="mta",client_name="example.org,[194.177.17.24]",resolved=OK,to="[email protected]",direction="in",message_length=6832079,virus="",disposition="Accept",classifier="Not,Spam",subject="=?windows-1255?B?Rlc6IEZ3OiDg5fDp5fog+fno5fog7Pf46eHp7S3u4+Tp7SE=?="

I tried using CSV module and it didn't fit, cause i haven't found a way to ignore what's quoted. Pyparsing looked like a better answer but i haven't found a way to declare all the grammars.

Currently, i am using my old Perl script to parse it, but i want this written in Python. if you need my Perl snippet i will be glad to provide it.

Any help is appreciated.

© Stack Overflow or respective owner

Related posts about pyparsing

Related posts about python