mercredi 6 mai 2015

Adjusting code to deal with bad data

I have a code which goes through a data set comprised of three columns. The first column in an ID of the group to which the data of interests belongs, columns two and three which I'll call X and Y are the data of interest.I have run into two problems with the data and now need to adjust my code to work around them. When I originally wrote the code I was under the impression that the values in the first column increment by 100000000 but I have found out that there are a few places where it will jump from say 400000000 to 600000000 with no 500000000.So I need a way to keep incrementing the count without the indexes of the getting out of sync. The next problem is that the data in the second column is supposed to start at some value for and then decrease, but I have found places where it actually increases. So I need a way to break out of the loop where the data is bad and resume the processing.

The part of the code in question is

count = 100000000
l =len(somelist)
 for i in range(l):
   if ID[i] == count: 
     for j in range(i,l):   
       if X[j]<= X[i]/2:
          filesave(X[j],Y[j])
          count+=100000000
          break

I tried doing this

 count = 100000000
    l =len(somelist)
     for i in range(l):
       if ID[i] == count: 
         for j in range(i,l):   
           if X[j]<= X[i]/2:
              filesave(X[j],Y[j])
              count+=100000000
              break             
           else:
              count+=100000000
              break             

But that resulted in an empty file.

Here is a sample of the data I am using. It has been edited for length.

18861900000000      15113492889600.0        0.22
18861900000000  15261750001664.0        0.24
18861900000000  15287913021440.0        0.27
18861900000000  14869304705024.0        0.29
18861900000000  14799536652288.0        0.32
18861900000000  14973956784128.0        0.35
18861900000000  15148376915968.0        0.37
18861900000000  183141007360.0  4.68
18862000000000  18575731458048.0        0.0
18862000000000  18872243585024.0        0.01
18862000000000  18505963405312.0        0.03
18862000000000  18523403321344.0        0.05
18862000000000  18261773123584.0        0.06
18862000000000  17886770888704.0        0.08
18862000000000  18000145022976.0        0.1
18862000000000  18122239115264.0        0.12
18862000000000  17293742440448.0        0.14
18862000000000  17468162572288.0        0.16
18862000000000  17250138456064.0        0.18
18862000000000  16587341955072.0        0.2
18862000000000  17110601302016.0        0.22
18862000000000  17476884627456.0        0.24
18862000000000  13866389995520.0        0.27
18862000000000  14625117569024.0        0.29
18862000000000  14363487371264.0        0.32
18862000000000  226746007552.0  2.89
18862100000000  18575731458048.0        0.0     column two values decrease then increase.
18862100000000  18035026952192.0        0.01
18862100000000  18898405556224.0        0.03
18862100000000  18287937191936.0        0.05
18862100000000  24915895910400.0        0.06
18862100000000  27863596138496.0        0.08
18862100000000  27165913513984.0        0.1
18862100000000  23468210913280.0        0.12    JUMPS FROM 1886210000000 to 18862300000000
18862300000000  18575731458048.0        0.0
18862300000000  18863523627008.0        0.01
18862300000000  18819917545472.0        0.03
18862300000000  19064105730048.0        0.05
18862300000000  19229803806720.0        0.06
18862300000000  19665856233472.0        0.08
18862300000000  19456549978112.0        0.1
18862300000000  18976895664128.0        0.12
18862300000000  18689103495168.0        0.14
18862300000000  18226891194368.0        0.16
18862300000000  17851886862336.0        0.18
18862300000000  17293742440448.0        0.2
18862300000000  17162927341568.0        0.22
18862300000000  17433279594496.0        0.24
18862300000000  16709436047360.0        0.27
18862300000000  16229781733376.0        0.29
18862300000000  15706521337856.0        0.32
18862300000000  16003035561984.0        0.35
18862300000000  15000119803904.0        0.37
18862300000000  15558263177216.0        0.4
18862300000000  11319858167808.0        0.47
18862300000000  10552410636288.0        0.53
18862300000000  9715194003456.0 0.61
18862300000000  9375074746368.0 0.69
18862300000000  9558215884800.0 0.78
18862300000000  8642510716928.0 0.89
18862400000000  18575731458048.0        0.0
18862400000000  18523403321344.0        0.01
18862400000000  18348985286656.0        0.03
18862400000000  18026306994176.0        0.05
18862400000000  17817004933120.0        0.06
18862400000000  17782118809600.0        0.08
18862400000000  14642558533632.0        0.1
18862400000000  14337324351488.0        0.12
18862400000000  14433254375424.0        0.14

Aucun commentaire:

Enregistrer un commentaire