Re: [Tutor] Parsing text file

2007-05-14 Thread Dave Kuhlman
On Sun, May 13, 2007 at 03:04:36PM -0700, Alan wrote: > I'm looking for a more elegant way to parse sections of text files that > are bordered by BEGIN/END delimiting phrases, like this: > > some text > some more text > BEGIN_INTERESTING_BIT > someline1 > someline2 > someline3 > END_INTERESTING_B

Re: [Tutor] Parsing text file

2007-05-13 Thread Alan Gauld
"Alan" <[EMAIL PROTECTED]> wrote > I'm looking for a more elegant way to parse sections of text files > that > are bordered by BEGIN/END delimiting phrases, like this: > > some text > BEGIN_INTERESTING_BIT > someline1 > someline3 > END_INTERESTING_BIT > more text > > What I have been doing is cl

Re: [Tutor] Parsing text file

2007-05-13 Thread John Fouhy
On 14/05/07, Alan <[EMAIL PROTECTED]> wrote: > I'm looking for a more elegant way to parse sections of text files that > are bordered by BEGIN/END delimiting phrases, like this: > > some text > some more text > BEGIN_INTERESTING_BIT > someline1 > someline2 > someline3 > END_INTERESTING_BIT > more t

[Tutor] Parsing text file

2007-05-13 Thread Alan
I'm looking for a more elegant way to parse sections of text files that are bordered by BEGIN/END delimiting phrases, like this: some text some more text BEGIN_INTERESTING_BIT someline1 someline2 someline3 END_INTERESTING_BIT more text more text What I have been doing is clumsy, involving conver

Re: [Tutor] parsing text

2007-03-24 Thread Kent Johnson
Alan Gauld wrote: >> 1.) when i do readlines and create a list and then print the list it >> adds a blank line between every line of text > > I suspect that's because you are reading a newline character > from the file and print adds a newline of its own. You need to > use rstrip() to take out th

Re: [Tutor] parsing text

2007-03-24 Thread Alan Gauld
"Jay Mutter III" <[EMAIL PROTECTED]> wrote > i have the following text: > > Barnett, John B., assignor of one-half to R. N. Tutt, Kansas City, > Mo.Automatic display-sign.No. 1,330 411-Apr. 13 ; v. 273 ; > p. > 193. > Barnett, John II.. Tettenhall, England. Seat of > motorcars.

[Tutor] parsing text

2007-03-24 Thread Jay Mutter III
Kent thanks for this as I was clearly confused with regards to string and list of strings. I am, however, still having difficulty with how to solve a problem involving a related issue. i have the following text: Barnett, John B., assignor of one-half to R. N. Tutt, Kansas City, Mo.Auto

Re: [Tutor] Parsing text file with Python

2007-03-23 Thread Alan Gauld
"Jay Mutter III" <[EMAIL PROTECTED]> wrote > 1.) Are there better ways to write this? There are always other ways, as to which is better depends on your judgement criteria. Your way works. > 2.) As it writes out the one group to the new file for companies it > is as if it leaves blank lines behi

[Tutor] Parsing text file with Python

2007-03-23 Thread Jay Mutter III
Script i have to date is below and Thanks to your help i can see some daylight but I still have a few questions 1.) Are there better ways to write this? 2.) As it writes out the one group to the new file for companies it is as if it leaves blank lines behind for if I don't have the elif len