* Christian Witts <cwi...@compuscan.co.za> [2009-11-18 09:53:15 +0200]:
> Date: Wed, 18 Nov 2009 09:53:15 +0200 > From: Christian Witts <cwi...@compuscan.co.za> > To: Antonio de la Fuente <t...@muybien.org> > CC: Python Tutor mailing list <tutor@python.org> > Subject: Re: [Tutor] Introduction - log exercise > User-Agent: Thunderbird 2.0.0.23 (X11/20090817) > Message-ID: <4b03a7e...@compuscan.co.za> > > How I would process it: > > from sys import argv, exit > import gzip > > if __name__ == '__main__': > try: > fIn = gzip.open(argv[1]) > except IOError: > exit('Cannot open file specified.\n') > > fOut = open('outputFile', 'a') > > datablock = [] > discard = False > for line in fIn: > if line.strip(): > if line.strip() == 'foo': > discard = True > else: > datablock.append(line) > else: > if discard: > datablock = [] > discard = False > else: > fOut.write(''.join(datablock)) > > fIn.close() > fOut.close() I've borrowed a couple of things from your script. It is educative for me to see different ways of solving the problem. Thank you. > > -- > Kind Regards, > Christian Witts > Business Intelligence > > C o m p u s c a n | Confidence in Credit > > Telephone: +27 21 888 6000 > National Cell Centre: 0861 51 41 31 > Fax: +27 21 413 2424 > E-mail: cwi...@compuscan.co.za > > NOTE: This e-mail (including attachments )is subject to the disclaimer > published at: http://www.compuscan.co.za/live/content.php?Item_ID=494. > If you cannot access the disclaimer, request it from > email.disclai...@compuscan.co.za or 0861 514131. > > National Credit Regulator Credit Bureau Registration No. NCRCB6 > > -- ----------------------------- Antonio de la Fuente MartÃnez E-mail: t...@muybien.org ----------------------------- ... ich bin in einem dusenjet ins jahr 53 vor chr ... ich lande im antiken Rom ... einige gladiatoren spielen scrabble ... ich rieche PIZZA ... _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor