November 9th, 2012, 10:27 PM
Join Date: Oct 2011
Time spent in forums: 5 h 39 m 44 sec
Reputation Power: 0
Originally Posted by WandyLau
I wrote some lines to extract the duplicated data from a piece of sorted data about 496 ,whose is formatted as "12 23 34 45 1234". I just want to get the ones who have the same last for numbers.And I have already known that there are 48 couples in all .So I wrote a piece of script but I only got a half ,just 24 couples.I checked that it just skipped some data.I can't understand it. Perhaps some bugs exist in my lines ,but I can not figure it out .Some body helps me please. Thank a lot in advance!! Code as follows>>
f = open("bit16_21",'r')
lines = f.readlines()
fobj = open('dup','w')
i = 0
line = lines[i]
j = i+1
if j<496 and line[9:] == lines[j][9:]:
i += 1
And I wonder if I do not know that it has 48 couples. Some one piece maybe have 3 or more duplicated ones how to get all the duplicated ones.I just trapped by this .
Yeah,I got the silly bug ,I counted the wrong number which should be like :line[11:] == lines[j][11:] . OMG，It nearly drived me out of my mind ,this little bug . Small mind-absence results in big mistake.
Now I wonder if there are more than two duplicated ones.How to handle it.....