I have a numpy structured array which contains string and float. I want to save this structured array as it is into a csv file. The simplified version of my procedure is like this.
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.000000
in foo.csv, but it gives me b'string',0.000000
where does this quotation mark and this b
comes from? How can I get rid of it?
I can use readline()
and manually get rid of this but is there any clever way to do this.
Thank you very much.