Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5511 > unrolled thread

Re: Convert AWK regex to Python

Started byJ <jnr.gonzalez@googlemail.com>
First post2011-05-16 03:57 -0700
Last post2011-05-16 03:57 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Re: Convert AWK regex to Python J <jnr.gonzalez@googlemail.com> - 2011-05-16 03:57 -0700

#5511 — Re: Convert AWK regex to Python

FromJ <jnr.gonzalez@googlemail.com>
Date2011-05-16 03:57 -0700
SubjectRe: Convert AWK regex to Python
Message-ID<mailman.1640.1305543472.9059.python-list@python.org>
Hello Peter, Angelico,

Ok lets see, My aim is to filter out several fields from a log file and write them to a new log file.  The current log file, as I mentioned previously, has thousands of lines like this:-
2011-05-16 09:46:22,361 [Thread-4847133] PDU D <G_CC_SMS_SERVICE_51408_656.O_ CC_SMS_SERVICE_51408_656-ServerThread-VASPSessionThread-7ee35fb0-7e87-11e0-a2da-00238bce423b-TRX - 2011-05-16 09:46:22 - OUT - (submit_resp: (pdu: L: 53 ID: 80000004 Status: 0 SN: 25866) 98053090-7f90-11e0-a2da-00238bce423b (opt: ) ) >

All the lines in the log file are similar and they all have the same length (same amount of fields).  Most of the fields are separated by spaces except for couple of them which I am processing with AWK (removing "<G_" from the string for example).  So in essence what I want to do is evaluate each line in the log file and break them down into fields which I can call individually and write them to a new log file (for example selecting only fields 1, 2 and 3).

I hope this is clearer now

Regards,

Junior

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web