numpy.savetxt without hash mark at beginning of header line
Question:
When I try to save a matrix with header, a hash mark and a space (# ) appear on the first line:
input:
np.savetxt(filename,data, fmt='%i %i %i %i %s',delimiter='t',header="atbtctdte")
output:
# a b c d e
0 0 0 0 bla
0 0 0 0 bla
1 1 1 1 bla
1 1 1 1 bla
Any hint why? How could I remove it?
Answers:
it inserts the # because that line is a comment, and the default character for comments is the symbol #, as you can read in the documentation here.
If you want to get rid of it, pass comments=''
as option to savetxt.
When I try to save a matrix with header, a hash mark and a space (# ) appear on the first line:
input:
np.savetxt(filename,data, fmt='%i %i %i %i %s',delimiter='t',header="atbtctdte")
output:
# a b c d e
0 0 0 0 bla
0 0 0 0 bla
1 1 1 1 bla
1 1 1 1 bla
Any hint why? How could I remove it?
it inserts the # because that line is a comment, and the default character for comments is the symbol #, as you can read in the documentation here.
If you want to get rid of it, pass comments=''
as option to savetxt.