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
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
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
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
[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
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
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