title: getting one matrix from each of the files in a folder and sum the matrices
body: <p>I was trying to read multiple files in a folder and get one matrix from each of them and sum all of the matrices.
  script for reading only one file and it works well(md.MCERunFile Item2d is some modules that existed for data reading):</p>
  
  <pre><code> outfile=md.MCERunfile('/somepath/filename') 
   rn_matrix=outfile.Item2d('IV', 'Rn_C%i')
   Shape=np.shape(rn_matrix)
   rn_matrix_float = np.array([]).reshape(0,55)
   for x in range(Shape[0]):
       row = map(float, rn_matrix[x])
       rn_matrix_float=np.vstack([rn_matrix_float, row])  
  </code></pre>
  
  <p>The final output rn_matrix_float is a 32 by 64 numpy array</p>
  
  <p>Now I tried:</p>
  
  <pre><code>path = '/somepath/*.xxx' 
  files = glob.glob(path)
  final_matrix=np.zeros((32, 64))
  for j in range(0,len(files)):
       outfile = md.MCERunfile(files[j])
       rn_matrix=outfile.Item2d('IV', 'cut_rec_C%i')
       Shape=np.shape(rn_matrix)
       for x in range(Shape[0]):
           rn_matrix_float = np.array([]).reshape(0,64)
           row = map(float, rn_matrix[x])
           rn_matrix_float=np.vstack([rn_matrix_float, row]) 
       final_matrix=final_matrix+rn_matrix_float
  </code></pre>
  
  <p>I think my mistake is that I have already defined outfile and rn_matrix in the loop, that make every rn_matrix_float to be exactly the same instead of reading data from different files, so the final_matrix is a summation of same arrays. But I don't know how to fix it.</p>