Parsing Text file

sas429s at gmail.com sas429s at gmail.com
Tue Jul 2 15:30:07 EDT 2013


Somemore can be anything for instance:

Sometext
mail
maskit

Sometext
rupee
dollar
maskit

and so on..

Is there a way I can achieve this?

On Tuesday, July 2, 2013 2:24:26 PM UTC-5, Neil Cerutti wrote:
> On 2013-07-02, sas429s at gmail.com <sas429s at 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




More information about the Python-list mailing list