Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread Alex Martelli
dawenliu <[EMAIL PROTECTED]> wrote: > Hi, I have a file with this content: > xxx xx x xxx > 1 > 0 > 0 > 0 > 1 > 1 > 0 > (many more 1's and 0's to follow) > y yy yyy yy y yyy > > The x's and y's are FIXED and known words which I will ignore, such as > "This is t

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread dawenliu
I've changed the code a little bit and works fine now: inf = open('input.txt') out = open('output.txt', 'w') skips = [ 'xxx xx x xxx', 'y yy yyy yy y yyy'] for line in inf: flag = 0 for skip in skips: if skip in line: flag = 1 continue i

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread dawenliu
Thanks Kent. The code looks reasonable, but the result is that, the output file comes out identical as the input file, with all the and remaining inside. -- http://mail.python.org/mailman/listinfo/python-list

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread Daniel Bowett
dawenliu wrote: > Hi, I have a file with this content: > xxx xx x xxx > 1 > 0 > 0 > 0 > 1 > 1 > 0 > (many more 1's and 0's to follow) > y yy yyy yy y yyy > > The x's and y's are FIXED and known words which I will ignore, such as > "This is the start of the file"

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread Kent Johnson
dawenliu wrote: > Hi, I have a file with this content: > xxx xx x xxx > 1 > 0 > 0 > 0 > 1 > 1 > 0 > (many more 1's and 0's to follow) > y yy yyy yy y yyy > > The x's and y's are FIXED and known words which I will ignore, such as > "This is the start of the file"

extracting numbers from a file, excluding fixed words

2005-10-29 Thread dawenliu
Hi, I have a file with this content: xxx xx x xxx 1 0 0 0 1 1 0 (many more 1's and 0's to follow) y yy yyy yy y yyy The x's and y's are FIXED and known words which I will ignore, such as "This is the start of the file" and "This is the end of the file". The dig