Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Neil Cerutti Newsgroups: comp.lang.python Subject: Re: Parsing Text file Date: 2 Jul 2013 19:24:26 GMT Organization: Norwich University Lines: 31 Message-ID: References: <08ae2828-1532-47b6-a9cb-208549189467@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net k+5775Gp5vJKGVVxY8ZrZQGkUU2lU+SmzBG1x+0H9QUf0VDg0K Cancel-Lock: sha1:zXoOqYWEp8Dr31Q5rRJdFxpbiWs= User-Agent: slrn/0.9.9p1/mm/ao (Win32) Xref: csiph.com comp.lang.python:49647 On 2013-07-02, sas429s@gmail.com wrote: > I have a text file like this: > > Sometext > Somemore > Somemore > maskit > > Sometext > Somemore > Somemore > Somemore > maskit > > Sometext > Somemore > maskit > > I want to search for the string maskit in this file and also > need to print Sometext above it..SOmetext location can vary as > you can see above. > > In the first instance it is 3 lines above mask it, in the > second instance it is 4 lines above it and so on.. > > Please help how to do it? How can you tell the difference between Sometext and Somemore? -- Neil Cerutti