Re: start reading from certain line

2008-07-10 Thread Steven D'Aprano
On Wed, 09 Jul 2008 09:59:32 -0700, norseman wrote: I would use: readthem= 0 file=open(filename,'r') while readthem == 0: line=file.readline() if not line: break if 'Item 1' in line: readthem= 1 # print line # uncomment if 'Item 1' is to be printed

Re: start reading from certain line

2008-07-10 Thread jstrick
Here's a simple way to do it with a minimum amount of loopiness (don't forget to use 'try-except' or 'with' in real life): f = open(item1.txt) for preline in f: if Item 1 in preline: print preline, for goodline in f: # could put an end condition with a 'break'

Re: start reading from certain line

2008-07-10 Thread Iain King
On Jul 10, 2:45 pm, jstrick [EMAIL PROTECTED] wrote: Here's a simple way to do it with a minimum amount of loopiness (don't forget to use 'try-except' or 'with' in real life): f = open(item1.txt) for preline in f:     if Item 1 in preline:         print preline,         for goodline in f:

Re: start reading from certain line

2008-07-10 Thread Iain King
On Jul 10, 4:54 pm, Iain King [EMAIL PROTECTED] wrote: On Jul 10, 2:45 pm, jstrick [EMAIL PROTECTED] wrote: Here's a simple way to do it with a minimum amount of loopiness (don't forget to use 'try-except' or 'with' in real life): f = open(item1.txt) for preline in f:     if Item 1

start reading from certain line

2008-07-09 Thread antar2
I am a starter in python and would like to write a program that reads lines starting with a line that contains a certain word. For example the program starts reading the program when a line is encountered that contains 'item 1' The weather is nice Item 1 We will go to the seaside ... Only the

Re: start reading from certain line

2008-07-09 Thread Diez B. Roggisch
antar2 wrote: I am a starter in python and would like to write a program that reads lines starting with a line that contains a certain word. For example the program starts reading the program when a line is encountered that contains 'item 1' The weather is nice Item 1 We will go to the

Re: start reading from certain line

2008-07-09 Thread Tim Cook
On Wed, 2008-07-09 at 03:30 -0700, antar2 wrote: I am a starter in python and would like to write a program that reads lines starting with a line that contains a certain word. For example the program starts reading the program when a line is encountered that contains 'item 1' The weather

Re: start reading from certain line

2008-07-09 Thread Tim Cook
On Wed, 2008-07-09 at 03:30 -0700, antar2 wrote: I am a starter in python and would like to write a program that reads lines starting with a line that contains a certain word. For example the program starts reading the program when a line is encountered that contains 'item 1' The weather

Re: start reading from certain line

2008-07-09 Thread A.T.Hofkamp
On 2008-07-09, antar2 [EMAIL PROTECTED] wrote: I am a starter in python and would like to write a program that reads lines starting with a line that contains a certain word. For example the program starts reading the program when a line is encountered that contains 'item 1' The weather is

Re: start reading from certain line

2008-07-09 Thread norseman
Tim Cook wrote: On Wed, 2008-07-09 at 03:30 -0700, antar2 wrote: I am a starter in python and would like to write a program that reads lines starting with a line that contains a certain word. For example the program starts reading the program when a line is encountered that contains 'item 1'