Reputation: 129
I am writing the following command:
np.savetxt('File1', File1, delimiter = ',\n')
The problem is when I open File1 in NotePad (Windows), all the numerical values I calculated come out on one line. I want each data value to start on a new line.
For example, I get: 123456
instead of:
1
2
3
4
5
6
I have tried using delimiter and newline in parameters but no luck.
Note: this does work if I open WordPad but not NotePad for some reason.
Upvotes: 2
Views: 1730
Reputation: 402543
On windows, the separator is CRLF (carriage return + line feed). You can use \r\n
as a separator.
np.savetxt(..., newline='\r\n')
Alternatively, without loss in generality, import os
and use os.linesep
, as suggested by @SeanBreckenridge. This would be the best option in terms of portability.
import os
np.savetxt(..., newline=os.linesep)
Upvotes: 1