Qilong Ren wrote:
Hi, Shane,
Thanks for fast reply.
What I used is :
for line in open(FILE):
do stuff
I don't want to store all lines in a list because sometimes the file is very
large. We need to store the value of the previous line in a variable. Is that
right?
Hi,all
I am new to this list. And I am glade I am here.
I have a question. I need to do some text processing. I need to read from a
file line by line. If some line is met with some condition, the previous line
needs some modification. How to get the info of the previous line?
Thanks!
Qilong
lines = open('/tmp/foo.py',
r).read().splitlines()
previous_line =
''
Hi, Shane,
Thanks for fast reply.
What I used is :
for line in open(FILE):
do stuff
I don't want to store all lines in a list because sometimes the file is very
large. We need to store the value of the previous line in a variable. Is that
right?
Thanks,Qilong
-
On Mar 16, 3:51 pm, Shane Geiger [EMAIL PROTECTED] wrote:
lines = open('/tmp/foo.py',
r).read().splitlines()
previous_line =
''
for line in
lines:
if foo in
line:
print found foo in the current line. The previous line is:
+
previous_line
previous_line =
line
On Mar 16, 3:51 pm, Shane Geiger [EMAIL PROTECTED] wrote:
lines = open('/tmp/foo.py',
r).read().splitlines()
previous_line =
''
On 3/16/07, Qilong Ren [EMAIL PROTECTED] wrote:
I have a question. I need to do some text processing. I need to read from a
file line by line. If some line is met with some condition, the previous
line needs some modification. How to get the info of the previous line?
I would do something like
On Mar 16, 5:10 pm, [EMAIL PROTECTED] wrote:
On Mar 16, 3:51 pm, Shane Geiger [EMAIL PROTECTED] wrote:
lines = open('/tmp/foo.py',
r).read().splitlines()
previous_line =
''
for line in
lines:
if foo in
line:
print found foo in the current line. The previous