Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-28 Thread spir
Le Mon, 27 Apr 2009 23:29:13 -0400, Dan Liang danlian...@gmail.com s'exprima ainsi: Hi Bob, Shantanoo, Kent, and tutors, Thank you Bob, Shantanoo, Kent for all the nice feedback. Exception handling, the concept of states in cs, and the use of the for loop with offset helped a lot. Here is

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-27 Thread Dan Liang
Hi Bob, Shantanoo, Kent, and tutors, Thank you Bob, Shantanoo, Kent for all the nice feedback. Exception handling, the concept of states in cs, and the use of the for loop with offset helped a lot. Here is the code I now have, based on your suggestions, and it does what I need: ListLines = [

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-26 Thread Kent Johnson
On Sat, Apr 25, 2009 at 2:11 PM, Dan Liang danlian...@gmail.com wrote: Hi Bob and tutors, Thanks Bob for your response! currently I have the current code, but it does not work: ListLines= [] for line in open('test.txt'):     line = line.rstrip()     ListLines.append(line) This could be

[Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread Dan Liang
Dear Tutors, I have a file from which I want to extract lines that end in certain strings and print to a second file. More specifically, I want to: 1) iterate over each line in the file, and if it ends in yes, print it. 2) move to the line following the one described in #1 above, and if it ends

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread bob gailer
Dan Liang wrote: Dear Tutors, I have a file from which I want to extract lines that end in certain strings and print to a second file. More specifically, I want to: 1) iterate over each line in the file, and if it ends in yes, print it. 2) move to the line following the one described in #1

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread Dan Liang
Hi Bob and tutors, Thanks Bob for your response! currently I have the current code, but it does not work: ListLines= [] for line in open('test.txt'): line = line.rstrip() ListLines.append(line) for i in range(len(ListLines)): if ListLines[i].endswith(yes) and

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread Shantanoo Mahajan (शंत नू महा जन)
On 25-Apr-09, at 11:41 PM, Dan Liang wrote: Hi Bob and tutors, Thanks Bob for your response! currently I have the current code, but it does not work: ListLines= [] for line in open('test.txt'): line = line.rstrip() ListLines.append(line) for i in range(len(ListLines)): if

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread bob gailer
Dan Liang wrote: Hi Bob and tutors, Thanks Bob for your response! currently I have the current code, but it does not work: [snip] Thank you for code, sample data and more complete specs. Lines in the file look like following: word1 word2 word3 word4 yes word1 word2 word3 word4 no