Re: [Tutor] Python regular expression

2004-12-03 Thread Alan Gauld
t; <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, December 03, 2004 9:23 PM Subject: [Tutor] Python regular expression > Dear group, > > I have a file with 645,984 lines. This file is > composedcompletely of bocks. > > For e.g. > > [Unit111] > Na

Re: [Tutor] Python regular expression

2004-12-03 Thread Rick Muller
Well, you could *try* ;-). Okay, here's a one-pass approach: #!/usr/bin/env python import re # Regular expressions stolen from PyCookbook: # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/132326 sec = re.compile(r'^\[(.*)\]') eq = re.compile(r'^([^=]+)=(.*)') def main(fname='file.ini'

Re: [Tutor] Python regular expression

2004-12-03 Thread Max Noel
On Dec 3, 2004, at 21:34, Rick Muller wrote: The file type you mention is also called an INI file, and is used for Windows initialization scripts, among other things. There's a nice recipe on this in the Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65334 This will read y

Re: [Tutor] Python regular expression

2004-12-03 Thread Rick Muller
The file type you mention is also called an INI file, and is used for Windows initialization scripts, among other things. There's a nice recipe on this in the Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65334 This will read your file in as a dictionary. You can then d

[Tutor] Python regular expression

2004-12-03 Thread kumar s
Dear group, I have a file with 645,984 lines. This file is composedcompletely of bocks. For e.g. [Unit111] Name=NONE Direction=2 NumAtoms=16 NumCells=32 UnitNumber=111 UnitType=3 NumberBlocks=1 [Unit111_Block1] Name=31318_at BlockNumber=1 NumAtoms=16 NumCells=32 StartPosition=0 StopPosition=1