Guest User

Untitled

a guest
Jun 14th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. 4.7 3.9 5.9 6.2 6.6 6.6 6.5 4.7 5.5 11.2
  2. 21.9 12.4 5.6 4.5 5.8 6.7 5.4 3.6 3.9 0.7 0.8
  3.  
  4. File 1:
  5. 1 2 3 4 5
  6.  
  7. File 2:
  8. 5 4 3 2 1
  9.  
  10. File 3:
  11. 0 3 0 3 0
  12.  
  13. Array = {1,2,3,4,5}
  14.  
  15. Array = {1+5, 2+4, 3+3, 4+2, 5+1} = {6, 6, 6, 6, 6}
  16.  
  17. Array = {6+0, 6+3, 6+0, 6+3, 6+0} = {6, 9, 6, 9, 6}
  18.  
  19. Result = {6/3, 9/3, 6/3, 9/3, 6/3} = {2,3,2,3,2}
  20.  
  21. import os
  22. flist = os.listdir(fdir)
  23.  
  24. import numpy as np
  25. numbers = [] #list of files numbers lists
  26. for text in flist:
  27. with open(filename,'r') as f:
  28. ftext = f.read().split() #the file has only space-separated numbers
  29. ftext = [float(n) for n in ftext]
  30. numbers.append( np.array( ftext ) )
  31.  
  32. numbers = np.vstack(numbers)
  33.  
  34. sum_over_first_cells = np.sum( numbers[:,0] )
Add Comment
Please, Sign In to add comment