[Tutor] Parsing several files
Que Prime
queprime at gmail.com
Fri Aug 3 18:07:37 CEST 2007
With the help of a tutor I was able to get the following code to work the
way I want, but I'd like for it to parse through several files in one folder
and create one output file.
I'm thinking I need to add something like:
def grab_files(files = []):
found = []
if files != None:
Here is the original:
import re
infile = open("in.txt","r")
outfile = open("out.txt","w")
patt = re.compile(r'.*src=([\d\.]*) dst=(10.52.10.10.*)')
for line in infile:
m = patt.match(line)
if m:
outfile.write('src=%s dst=%s\n' % m.groups())
infile.close()
outfile.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070803/50793698/attachment.html
More information about the Tutor
mailing list