Lany
Lany

Reputation: 1

why there is a "#" in header

There is always a # in the first column of my header:

np.savetxt((self.foldername + '/' + 'XYZ.csv'), XYZ, fmt='%1.6f', delimiter=',',header="X(um),Y(um),Z(nm))

I got the header like this

#X(um),Y(um),Z(nm)

How to avoid the #.

Upvotes: 0

Views: 146

Answers (2)

BlooB
BlooB

Reputation: 965

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.

from: numpy.savetxt without hash mark at beginning of header line

Upvotes: 0

Paul Panzer
Paul Panzer

Reputation: 53089

Here is the relevant bit from the loadtxt docstring describing the comments keyword and its effect on the header and other things.

comments : str, optional String that will be prepended to the header and footer strings, to mark them as comments. Default: '# ', as expected by e.g. numpy.loadtxt.

   .. versionadded:: 1.7.0

Upvotes: 1

Related Questions