T
trias
Hi,
I have this little script:
import csv
import numpy
signal=[]
ref=[]
for x in csv.reader(open('reffile.csv').readlines()):
ref.append(x)
for x in csv.reader(open('signalfile.csv').readlines()):
signal.append(x)
signalarray=numpy.array(signal, dtype=float)
signaldict={}
signaldict.update(dict(signalarray))
intarray=[0.0 for x in range(301)]
cntarray=[0 for x in range(301)]
for line in ref:
print line
locstr=line[1]
endstr=line[2]
loc=float(locstr)
end=float(endstr)
print loc
print end
i=0
while float(i) <= 300.0:
if signaldict.has_key(end+float(i)):
expr=signaldict[end+float(i)]
print expr
intarray+=expr
cntarray+=1
y=i
i+=1
print intarray
print cntarray
fo=file('outfile.txt','w')
s=str(intarray)
fo.write(s)
fo.close()
So on the above I am appending values from signaldict indexed by i for every
object in the ref list. This way I calculate the sum of all values with
similar indexing i value. Would I be able to store the signaldict for
every line individually in a multidimensional array?
cheers
I have this little script:
import csv
import numpy
signal=[]
ref=[]
for x in csv.reader(open('reffile.csv').readlines()):
ref.append(x)
for x in csv.reader(open('signalfile.csv').readlines()):
signal.append(x)
signalarray=numpy.array(signal, dtype=float)
signaldict={}
signaldict.update(dict(signalarray))
intarray=[0.0 for x in range(301)]
cntarray=[0 for x in range(301)]
for line in ref:
print line
locstr=line[1]
endstr=line[2]
loc=float(locstr)
end=float(endstr)
print loc
print end
i=0
while float(i) <= 300.0:
if signaldict.has_key(end+float(i)):
expr=signaldict[end+float(i)]
print expr
intarray+=expr
cntarray+=1
y=i
i+=1
print intarray
print cntarray
fo=file('outfile.txt','w')
s=str(intarray)
fo.write(s)
fo.close()
So on the above I am appending values from signaldict indexed by i for every
object in the ref list. This way I calculate the sum of all values with
similar indexing i value. Would I be able to store the signaldict for
every line individually in a multidimensional array?
cheers