Re: readline() - problem

2007-10-02 Thread Ricardo Aráoz
Paul Hankin wrote: > On Oct 2, 12:25 pm, [EMAIL PROTECTED] wrote: >> Hi! >> I'm a new user of python, and have problem. >> I have a plain ascii file: >> 11..1 >> 12..1 >> 11..1 >> I want to create a new file which contains only lines with '1' on 15th

Re: readline() - problem

2007-10-02 Thread Wayne Brehaut
On Tue, 02 Oct 2007 12:13:21 -, [EMAIL PROTECTED] wrote: >On 2 Pa , 13:39, Ben Finney <[EMAIL PROTECTED]> >wrote: >> [EMAIL PROTECTED] writes: >> > import string >> >> Why import 'string' if you're not using it? >> >> > f=open('/test/test.asc','r') >> > o=open('/test/out.asc','w') >> > for lin

Re: readline() - problem

2007-10-02 Thread piotr
On 2 Pa , 13:39, Ben Finney <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > import string > > Why import 'string' if you're not using it? > > > f=open('/test/test.asc','r') > > o=open('/test/out.asc','w') > > for line in f: > > s= f.readline() > > Your line object is already bound to

Re: readline() - problem

2007-10-02 Thread Wesley Brooks
Given a file: t.txt 1 2 1 1 3 1 ### end of file ### file = open('t.txt', 'r') for i, line in enumerate(file): print "Line:", i, "Text:", line would give the result: Line: 0 Text: 1 2 Line: 1 Text: 1 1 Line: 2 Text: 3 1 To check the third character in each line: for line in file

Re: readline() - problem

2007-10-02 Thread Ben Finney
[EMAIL PROTECTED] writes: > import string Why import 'string' if you're not using it? > f=open('/test/test.asc','r') > o=open('/test/out.asc','w') > for line in f: > s= f.readline() Your line object is already bound to the 'line' name in each iteration. You need to use that, not attempt to

Re: readline() - problem

2007-10-02 Thread Paul Hankin
On Oct 2, 12:25 pm, [EMAIL PROTECTED] wrote: > Hi! > I'm a new user of python, and have problem. > I have a plain ascii file: > 11..1 > 12..1 > 11..1 > I want to create a new file which contains only lines with '1' on 15th > position. > I've tried thi

readline() - problem

2007-10-02 Thread piotr
Hi! I'm a new user of python, and have problem. I have a plain ascii file: 11..1 12..1 11..1 I want to create a new file which contains only lines with '1' on 15th position. I've tried this: import string f=open('/test/test.asc','r') o=open('/test/ou