Python - File Processing
Revision as of 16:44, 4 April 2008 by PeterHarding (talk | contribs) (New page: Here is a fragment of code with some simple file parsing logic... <pre> def analyse(logfile): cnt = 0 lfd = open(logfile, 'r') for line in lfd.readlines(): if cnt ==...)
Here is a fragment of code with some simple file parsing logic...
def analyse(logfile):
cnt = 0
lfd = open(logfile, 'r')
for line in lfd.readlines():
if cnt == 11:
response_xml = line[:-1]
print "[[%s]]" % response_xml
print "Cnt -> %d" % cnt
cnt += 1
lfd.close()
ofd = open('response.xml', 'w')
ofd.write(response_xml)
ofd.close()
return response_xml