我想从控制台将小波系数放入 .csv 行。
下面的代码只能将一位数字放入 .csv 文件
def waveletdbbiorone(self): #function for Wavelets computation
for filename in glob.iglob ('*.tif'):
imgwbior = mahotas.imread (filename) #read the image
arraywbior = numpy.array([imgwbior])#make an array for pywt module
coefwbior = pywt.wavedec(arraywbior,'db1')#compute wavelet coefficients
arr = numpy.array([coefwbior])
np.set_printoptions(threshold=3)
# print arr
for elem in arr.flat[:50]:
#print('{}\t'.format(elem)) #this code puts the result to console
with open('сomput.csv', 'wb') as csvfile:
writer = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL)
writer.writerow([('{}\t'.format(elem))])
谢谢