1

I'm using the savetxt function (description here) to save a matrix to a txt file, and I wonder what does the 'newline' parameter do? Also the 'header' parameter doesn't seem to work with the latest numpy version.

LWZ
  • 11,670
  • 22
  • 61
  • 79

1 Answers1

3

It's for setting how the end of a line is represented for interoperability between Mac/Linux/Windows.

Windows typically represents a line end with a carriage return character followed by a linefeed character (\r\n).

Mac used to use just a carriage return, and much Microsoft Mac software still saves files this way, but has used a linefeed for the past decade or so (\n).

Linux has always used a linefeed as far as I know (\n).

blahdiblah
  • 33,069
  • 21
  • 98
  • 152
  • oh! that's what it is! Thanks! so will I have a problem copying the data file between Windows and Mac? – LWZ Jun 29 '12 at 19:23
  • As this has been a problem for the past ~2 decades, much software has adapted to accept either style. If the particular software you're using doesn't, there are numerous conversion utilities out there. Search 'mac windows newline conversion' or similar. – blahdiblah Jun 29 '12 at 19:26