1

I have the output from Python wavelet package:

 [[[[[[255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]
 ..., 
 [255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]]

[[255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]
 ..., 
 [255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]]

[[255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]
 ..., 
 [255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]]

..., 
[[255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]
 ..., 
 [255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]]

[[255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]
 ..., 
 [255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]]

[[255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]
 ..., 
 [255 255 255 255]
 [255 255 255 255]
 [255 255 255 255]]]]]]

I need to print it to terminal and to a .csv file in one line with tab separation and without brackets.

 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(precision=3)
         print arr
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
KvasDub
  • 281
  • 7
  • 16

1 Answers1

0

If you really want only one line use the iterator flat:

Python 3

>>> for elem in arr.flat:
        print('{}\t'.format(elem), end='')  
    255.0   255.0   255.0   255.0   255.0 .........

Python 2

>>> for elem in arr.flat:
        print '{}\t'.format(elem),
    255.0   255.0   255.0   255.0   255.0 .........
Mike Müller
  • 82,630
  • 20
  • 166
  • 161