How to multiply two columns of a data file and add them in python?
Question: I want to multiply the contents two columns of a file generated from a bash
script and then add them up to get the summation. The problem is the file
contains some special character on the last column which I cannot get rid of.
How do I read the following file and multiply col. 3 and col. 5 and then add
them up? I want to get sum = 4*821+3*28+4*1+6*1+5*13 ...

>   1. 0 0 4 0 821.00 95.02%
>   2. 0 0 3 0 28.00 3.24%
>   3. 0 1 4 0 1.00 0.12%
>   4. 0 0 6 0 1.00 0.12%
>   5. 0 0 5 0 13.00 1.50%
>

Normally I could have done it by

    
    
    flist = glob.glob(filename)
    
    fdata = []
    for f in flist:
      load = np.loadtxt(f)
      fdata.append(load) 
      fdata_arry=np.array(fdata)
    
    print fdata_arry
    
    c = fdata_arry[:,2]*fdata_arry[:,4] 
    d = np.sum(c) 
    

but in this case the last col. has a %sign which makes it difficult to read.
Is there a way to ignore the last column. This should be pretty basic but I'm
just a new programmer so your help is much appreciated. Thanks!


Answer: 
    import csv
    dat=open('dat','r')
    reader= csv.reader(dat, delimiter=' ')
    prod=0
    for row in reader:
        prod+=float(row[2])*float(row[4])
    
    prod
    # 3443.0
    

