[Tutor] Reading every 5th line
davidheiserca at gmail.com
davidheiserca at gmail.com
Sun Aug 8 16:49:41 CEST 2010
----- Original Message -----
From: "nitin chandra" <nitinchandra1 at gmail.com>
To: <DavidHeiserCA at gmail.com>
Sent: Sunday, August 08, 2010 7:29 AM
Subject: Re: [Tutor] Reading every 5th line
> Thank you all.
>
> @Dave - Thank you for the tip. No this is not a class exercise, that
> is assured.
>
> Will let know how much progress i made.
>
> Truly, I am still foggy, as to how to include it in code.
>
> Thanks
>
> Nitin
>
>>
>>
>> Try using "range(start, end, step)".
>>
>> If this is for a class exercise, it would be unfair to say more. If it's
>> not
>> for an assignment, I can show you more.
>>
>> Dave
>>
>>
This may help you get started.
FileNames = ["FileName01", "FileName02", ..., "FileName24"]
for File in FileNames:
List = open(File, 'r').readlines()
for Start in [[14, "%s-1" % File], [15,"%s-2" % File]]:
OutList = []
for Line in range(Start[0]-1, 3024, 5):
OutList.append(List[Line])
open(("%s.txt" % Start[1]), 'w').writelines(OutList)
P.S. My code writing style isn't very conventional.
More information about the Tutor
mailing list