Re: [Tutor] Tab delimited question

2010-12-13 Thread Martin A. Brown
Greetings Ben, : I'm searching line by line for certain tags and then printing the : tag followed by the word immediately following the tag. What you are describing is an awful lot like 'grep'. But, of course, many different sorts of file searching resemble grep. : So for example, suppose

Re: [Tutor] Tab delimited question

2010-12-13 Thread Joel Goldstick
On Mon, Dec 13, 2010 at 1:55 PM, Ben Ganzfried wrote: > I'm searching line by line for certain tags and then printing the tag > followed by the word immediately following the tag. > > So for example, suppose I had the following line of text in a file: > > mystring = "this is a key

Re: [Tutor] Tab delimited question

2010-12-13 Thread Alan Gauld
"Ben Ganzfried" wrote def test(infile, outfile): for line in infile: tagIndex = line.find("key") start = tagIndex + 4 stop = line[start:].find("\t") -1 if tagIndex != -1: print("start is: ", start) print("stop is: ", sto

[Tutor] Tab delimited question

2010-12-13 Thread Ben Ganzfried
I'm searching line by line for certain tags and then printing the tag followed by the word immediately following the tag. So for example, suppose I had the following line of text in a file: "this is a key test123 noisenoise noise noise noise" In this example, I would wan