I have a numpy structured array that contains a string and a float. I want to keep this structured array as it is in the csv file. A simplified version of my procedure is as follows.
structured_array = np.zeros((1,), dtype=[('string','a20'),('float','f8')])
structured_array['string'] = 'string'
structured_array['float'] = 0.0
np.savetxt('foo.csv', structured_array, delimiter=',',fmt='%s,%f')
I would expect string,0.000000in foo.csv, but it gives me b'string',0.000000where this quotation mark came from and this b? How can I get rid of it?
I can use readline()and get rid of it manually, but is there any smart way to do this.
Many thanks.
source
share