En Tue, 30 Oct 2007 09:14:08 -0300, Beema shafreen <[EMAIL PROTECTED]> escribió:
> hi everbody, > I have a file, > a b c > 1454 VALTGLTVAEYFR 8.9954e-07 > 1454 VALTGLTVAEYFR 0.00404626 > 1498 STLTDSLVSK 0.00404626 > 1505 TIAMDGTEGLVR 1.50931e-05 > 1528 GAEISAILEER 0.00055542 > 1528 GAEISAILEER 0.00055542 > 1538 YPIEHGIITNWDDMEK 0.0180397 > 1540 YPIEHGIITNWDDMEK 3.69329e-05 > 1552 AQIVGGFPIDISEAPYQISLR 0.015136 > > > The file has redundancy in lines , I have to print the line without > redundancy on consideration to the column c of the two lines which are > redundant and those that are having column c lesser value than the > other. > how do i do it. A manual, step-by-step procedure: 1) Open the file: f = open(...) 2) Iterate over the file contents: for line in f: 3) Split each line in its three fields: line.split() -> a,b,c 4) Remember to convert c to float 5) Append (a,b,c) to some list L (which should start empty) 6) When finished, sort the list: L.sort() 7) Iterate over L items: for a,b,c in L, keeping track of "previous" a and b values 8) If either a or b changed, print a, b and c. 9) Update the "previous" a and b values 10) When finished with L, you're done. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list