I have created a script for calculating the sum of all the values in 32th column which has comma as delimiter. My script is printing the values but unable to sum the values. What I am doing wrong? Below is my script:
import numpy as np
b=np.loadtxt(r'FileP3806520150316142845.txt',dtype=str,delimiter=',',skiprows=0,usecols=(31,))
print b
a = b[1].sum(0)
print a
I can print variable b, but not a.
python myreport.sh
['1' '438' '18' '987' '1472' '95' '52' '2' '22' '137' '7' '22']
Traceback (most recent call last):
File "myreport.sh", line 4, in <module>
a = b[1].sum(0)
TypeError: cannot perform reduce with flexible type
Also I am just running this script on one file. Can this be applied to all files in a folder or all files in a tar file?