hi all,<br>
<br>
i have a file of 3x3 matrix of decimal numbers(tab separated). like this :<br>
<br>
0.02    0.38    0.01<br>
0.04    0.32    0.00<br>
0.03    0.40    0.02<br>
<br>
now i want to read 1 row and get the sum of a particular row. but when
i am trying with the following code, i am getting errors :<br>
<br>
<u><b>code</b></u>:<br>
"<br>
ln1=open("A.txt","r+")    # file "A.txt" contains my matrix<br>
lines1=ln1.readlines()<br>
n_1=[ ]<br>
<br>
for p1 in range (0,len(lines1)):<br>
    f1=lines1[p1]<br>
    n_1.append((f1) )<br>
print n_1<br>
print  sum(n_1[0])<br>
<br>
"<br>
<br>
<u><b>output</b></u>:<br>
<br>
['0.0200\t0.3877\t0.0011\n', '0.0040\t0.3292\t0.0001\n',
'0.0355\t0.4098\t0.0028\n', '0.0035\t0.3063\t0.0001\n',
'0.0080\t0.3397\t0.0002\n']<br>
<br>
Traceback (most recent call last):<br>
  File "A_1.py", line 20, in <module><br>
    print sum(nodes_1[0])<br>
  File "/usr/lib/python2.5/site-packages/numpy/core/fromnumeric.py", line 993, in sum<br>
    return _wrapit(a, 'sum', axis, dtype, out)<br>
  File "/usr/lib/python2.5/site-packages/numpy/core/fromnumeric.py", line 37, in _wrapit<br>
    result = getattr(asarray(obj),method)(*args, **kwds)<br>
TypeError: cannot perform reduce with flexible type<br>
<br>
<br><u><b>
what I think:</b></u><br>
<br>
as the list is in form of   '0.0200\t0.3877\t0.0011\n'    ,  n_1[0]  takes it as a whole string   which includes "\t" , i think thats why they are giving error.<br>
<br>now how can i read only required numbers from this line  '0.0200\t0.3877\t0.0011\n'  and find their sum ?<br>
can you kindly help me out how to properly code thing .<br>
<br><br><br>thank you,<br><br>regards<br>