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


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

Re: Convert AWK regex to Python

Started byJ <jnr.gonzalez@googlemail.com>
First post2011-05-17 03:07 -0700
Last post2011-05-17 08:58 -0500
Articles 2 — 2 participants

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


Contents

  Re: Convert AWK regex to Python J <jnr.gonzalez@googlemail.com> - 2011-05-17 03:07 -0700
    Re: Convert AWK regex to Python harrismh777 <harrismh777@charter.net> - 2011-05-17 08:58 -0500

#5556 — Re: Convert AWK regex to Python

FromJ <jnr.gonzalez@googlemail.com>
Date2011-05-17 03:07 -0700
SubjectRe: Convert AWK regex to Python
Message-ID<c53b788e-8696-4571-9d9f-3f8177b8851e@glegroupsg2000goo.googlegroups.com>
Hello,

I have managed to get my script finished in the end by taking bits from everyone who answered.  Thank you so much.  the finished query string looks like this (still not the best but it gets the job done.  Once I learn to code more with Python I will probably go back to it and re-write it):-

# Log file to work on
filetoread = open("/tmp/pdu.log", "r")
# Perform filtering in the log file
text = filetoread.read()
text = text.replace("<G_", "")
text = text.replace(".", " ")
text = text.replace(r"(", " ")
filetoread.close()
# File to write output to
filetowrite = file("/tmp/pdu_filtered.log", "w")
# Write new log file
filetowrite.write(text)
filetowrite.close()
# Read new log and get required fields from it
filtered_log =  open("/tmp/pdu_filtered.log", "r")
filtered_line = filtered_log.readlines()
for line in filtered_line:
	field = line.split(" ")
	field5 = field[5].rsplit("_", 1)
	print field5[0], field[14], field[22]
print "Done"

[toc] | [next] | [standalone]


#5566

Fromharrismh777 <harrismh777@charter.net>
Date2011-05-17 08:58 -0500
Message-ID<M9vAp.225$wM1.205@newsfe05.iad>
In reply to#5556
J wrote:
> Hello,

Hello, J,

    This is totally off-topic, but I was wondering why you are posting 
with double messages (triple) all over the place?

    Your reply-to is set to comp.lang.python@googlegroups.com, and you 
cc to python-list@python.org...  and you're stuff is showing up in 
newsgroup comp.lang.python...

... did you know that all you need to do is use the newsgroup (use a 
client like sea monkey, or other... ) and your posts will show up in 
googlegroups, and will also be archived forever.... authomatically?

    Your messages are duplicating which is not only annoying on the 
surface, but also breaks the threads apart in a news client. What should 
appear (and does in googlegroups) as a single thread appears as many 
threads in the mail client; partly because of the RE: in the subject, 
and partly because of the reduplication.

    Just a heads up....


kind regards,
m harris

[toc] | [prev] | [standalone]


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


csiph-web