title: python stops working in the middle of dataset
body: <p>I wrote a script to read and plot data into the graphs. I have three input files</p>
  
  <ul>
  <li><p>wells.csv: list of observation wells that I want to create graph</p>
  
  <p>1201</p>
  
  <p>1202</p>
  
  <p>... </p></li>
  <li><p>well_summary_table.csv: contained information for each well (e.g. reference elevation, depth to water)</p>
  
  <p>Bore_Name     Ref_elev</p>
  
  <p>1201            20</p></li>
  <li><p>data.csv: contained observation data for each well (e.g. pH, Temp)</p>
  
  <p>RowId    Bore_Name     Depth     pH</p>
  
  <p>1          1201           2        7</p></li>
  </ul>
  
  <p>Not all wells in wells.csv have data to plot</p>
  
  <p>My script is as follow</p>
  
  <pre><code>well_name_list = []
  new_depth_list =[]
  pH_list = []
  from pylab import *
  infile = open("wells.csv",'r')
  for line in infile:
      line=line.strip('\n')
      well=line
      if not well in well_name_list:
          well_name_list.append(well)
  infile.close()
  for well in well_name_list:
      infile1 = open("well_summary_table.csv",'r')
      infile2 = open("data.csv",'r')
      for line in infile1:
          line = line.rstrip()
          if not line.startswith('Bore_Name'):
              words = line.split(',')
              well_name1 = words[0]
              if well_name1 == well:
                  ref_elev = words[1]
      for line in infile2:
          if not line.startswith("RowId"):
              line = line.strip('\n')
              words = line.split(',')
              well_name2 = words[1]
              if well_name2 == well:
                  depth = words[2]
                  new_depth = float(ref_elev) - float(depth)
                  pH = words[3]
                  new_depth_list.append(float(new_depth))
                  pH_list.append(float(pH))
                  fig.plt.figure(figsize = (2,2.7), facecolor='white')
                  plt.axis([0,8,0,60])
                  plt.plot(pH_list, new_depth_list, linestyle='', marker = 'o')
                  plt.savefig(well+'.png')
      new_depth_list = []
      pH_list = []
  infile1.close()
  infile2.close()
  </code></pre>
  
  <p>It works on more than half of my well list then it stops without giving me any error message. I don't know what is going on. Can anyone help me with that problem? Sorry if it is an obvious question. I am a newbie.</p>
  
  <p>Many thanks,</p>