[Tutor] Reading every 5th line

davidheiserca at gmail.com davidheiserca at gmail.com
Sun Aug 8 16:20:39 CEST 2010


----- Original Message ----- 
From: "nitin chandra" <nitinchandra1 at gmail.com>
To: <tutor at python.org>
Sent: Sunday, August 08, 2010 5:04 AM
Subject: [Tutor] Reading every 5th line


> Hello Everyone,
>
> I am to make a small programme for a friend of mine
> where i am to start reading from 14th (string) from a file and then
> read every 5th row.
>
> ie.
>
> in 1st read it reads the 14 row in a File, write to an OUTPUT-1 file
> Next reads 19th row, write to the OUTPUT-1 file
> then 24th row,... so on.
>
> and the second loop does is
>
> reads the 15th line as the first line from same input file and write
> to OUTPUT-2 file
> next reads 20th line / row, write to the OUTPUT-2 file
>
>
> I have tried various ways but some how i am ONLY able to do i simple
> read from one file and write to another.
>
> There are 3024 rows / lines PER file and there are 24 such file I need
> to run the programme on.
>
> I really need this on an urgent basis. can some one please help me in 
> this.
>
> Thanks in Advance
>
> Nitin
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor


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



More information about the Tutor mailing list