Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 4.7 3.9 5.9 6.2 6.6 6.6 6.5 4.7 5.5 11.2
- 21.9 12.4 5.6 4.5 5.8 6.7 5.4 3.6 3.9 0.7 0.8
- File 1:
- 1 2 3 4 5
- File 2:
- 5 4 3 2 1
- File 3:
- 0 3 0 3 0
- Array = {1,2,3,4,5}
- Array = {1+5, 2+4, 3+3, 4+2, 5+1} = {6, 6, 6, 6, 6}
- Array = {6+0, 6+3, 6+0, 6+3, 6+0} = {6, 9, 6, 9, 6}
- Result = {6/3, 9/3, 6/3, 9/3, 6/3} = {2,3,2,3,2}
- import os
- flist = os.listdir(fdir)
- import numpy as np
- numbers = [] #list of files numbers lists
- for text in flist:
- with open(filename,'r') as f:
- ftext = f.read().split() #the file has only space-separated numbers
- ftext = [float(n) for n in ftext]
- numbers.append( np.array( ftext ) )
- numbers = np.vstack(numbers)
- sum_over_first_cells = np.sum( numbers[:,0] )
Add Comment
Please, Sign In to add comment