Re: Simple text parsing gets difficult when line continues to next line
- From: Roberto Bonvallet <Roberto.Bonvallet@xxxxxxx>
- Date: Tue, 28 Nov 2006 18:13:07 +0000 (UTC)
Jacob Rael wrote:
[...]
I would line to identify if a line continues (if line.endswith('_'))
and concate with the next line:
line = line + nextLine
How can I get the next line when I am in a for loop using readlines?
Don't use readlines.
# NOT TESTED
program = open(fileName)
for line in program:
while line.rstrip("\n").endswith("_"):
line = line.rstrip("_ \n") + program.readline()
do_the_magic()
Cheers,
--
Roberto Bonvallet
.
- References:
- Simple text parsing gets difficult when line continues to next line
- From: Jacob Rael
- Simple text parsing gets difficult when line continues to next line
- Prev by Date: Reading text labels from a Win32 window
- Next by Date: Re: pyxpcom
- Previous by thread: Re: Simple text parsing gets difficult when line continues to next line
- Next by thread: Re: Simple text parsing gets difficult when line continues to next line
- Index(es):