I am trying to write a string and a float into a file using:
t=['SDSS J2000']
data=[10]
astropy.io.ascii.write([t,data] ,'data.dat',names=['name','num'],formats={'name':'%s','num':'%f'})
the output file is:
name num
"SDSS J2000" 10.000000
how can I write the string to file without the quotes, like this:
SDSS J2000 10.000000

You provided 2 data and 2 values, so
astropyquotes the data to be able to read it back.Do you really need
astropyfor this? Standard python does it easily usingstr.format:if you really want to achieve that using
astropyyou can usequotecharset to space (and use the option to avoid displaying header):this writes:
so too many spaces, expected when you try to twist the library's arm into writing data that cannot be read back reliably
EDIT: another way to do it is to let
astropywrite its quotes and remove them afterwards, usingio.StringIOto avoid writing/reading/writing to disk:file now contains: