Iteration through a text file.

Peter Hansen peter at engcorp.com
Wed Jun 4 14:04:26 EDT 2003


marcus wrote:
> 
> Forgive "newness"
> 
> I'm pretty sure I'm missing something very basic, but don't know where
> to look.
> 
> I have a text file that a Sys Admin is using a program to generate
> (don't know the program).  It contains a list of Servers, along with
> their "System Availablity" percentages. Some Servers the program
> cannot reach, and therefore it has errors in the text file instead of
> percentages.
> 
> I am trying to loop through the text file, looking for the word
> "Server."  If I find that word, I then print out the server name (will
> write out later to another file, but for now printing shows me where
> I'm at).
> 
> Then, I want to look for the phrase "System Availablilty."  If I find
> that phrase, then I'll print out the percentage.

You might want to post simple examples of the input you expect to
find and the output you want, so we don't have to reverse engineer
your intent from the code or the summary description.




More information about the Python-list mailing list