Have you looked at the ConfigParser module that was mentioned earlier today? Your file fits its format exactly...
But regular expressions can be used, try the intro in my tutorial, or the excellent HowTo on the Python web site... Alan G. ----- Original Message ----- From: "kumar s" <[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] > 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=15 > CellHeader=X Y PROBE FEAT QUAL EXPOS POS CBASE PBASE > TBASE ATOM INDEX CODONIND CODON REGIONTYPE REGION > Cell1=24 636 N control 31318_at 0 13 A A A 0 407064 -1 > -1 99 > Cell2=24 635 N control 31318_at 0 13 A T A 0 406424 -1 > -1 99 > Cell3=631 397 N control 31318_at 1 13 T A T 1 254711 > -1 -1 99 > > > > [Unit113] > Name=NONE > Direction=2 > NumAtoms=16 > NumCells=32 > UnitNumber=113 > UnitType=3 > NumberBlocks=1 > > [Unit113_Block1] > Name=31320_at > BlockNumber=1 > NumAtoms=16 > NumCells=32 > StartPosition=0 > StopPosition=15 > CellHeader=X Y PROBE FEAT QUAL EXPOS POS CBASE PBASE > TBASE ATOM INDEX CODONIND CODON REGIONTYPE REGION > Cell1=68 63 N control 31320_at 0 13 T A T 0 40388 -1 > -1 99 > Cell2=68 64 N control 31320_at 0 13 T T T 0 41028 -1 > -1 99 > Cell3=99 194 N control 31320_at 1 13 C C C 1 124259 -1 > -1 99 > > > > > > I have a file with identifiers that are found in the > first file as : > Name=31320_at > > > I am interested in getting lines of block that are > present in first to be written as a file. > > I am search: > > search = re.search ["_at") > > > my question: > how can i tell python to select some rows that have > particular pattern such as [Name] or Name of [Unit]. > is there any way of doing this. > please help me > > thanks > kumar > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > _______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor