for example: consider the contents of file1.txt:

1 0 9227 1152 34 2
2 111 7622 1120 34 2
3 68486 710 1024 14 2
6 265065 3389 800 22 2
7 393152 48438 64 132 3
8 412251 46744 64 132 3
9 430593 50866 256 95 4
10 430730 10770 256 95 4
11 433750 12701 256 14 3
12 437926 2794 64 34 2
13 440070 43 32 96 3
14 440102 44 32 96 3
15 440357 43 32 96 3
16 440545 43 32 96 3
17 440599 43 32 96 3
18 440625 43 32 96 3
19 440999 84 32 96 0
20 441574 44 32 96 3
which the contains n jobs with 6 fields(i,e column(0-5))

Now, for example, I take the first 19 jobs as history. Then I need to start reading from the 20th and so on comparing the columns 3,4,5 which matches with the above jobs in the history.For the first recent occurrence i,e 18 440625 43 32 96 3.I need to check the condition if col1 of the 20th job is greater than the (col1 * 1.1) of the first recent occurrence i,e 18th if true it add the col2 to a list and should read the next recent occurrence i,e 17th job and so on until the if condition fails.Then need to add the 20th line to history making the history count of 21 there by updating the history and so on till the end of the file is reached......... Can any one suggest a code in python by which its possible for me to read the 20st line and compare with the above history and update it such that as continue to 21,22,23------------------ until the end of the file is reached.The history also gets updated and a lists of col2 that matches the if condition is generated??

I would start by reading the file into a list:

fid=open('file1.txt')
lstData=fid.readlines()
fid.close()

Now the last record is: lstData[-1]

To loop through the records from the 2nd to last until the first,
for i in lstData[-2::-1]:

This question has already been answered. Start a new discussion instead.