My script writes to and creates a new file but it is currently making it in Mac EOL Conversion instead of Windows. This means that each line ends with only 'CR' instead of 'CR LF' which won't work for what i'm trying to do.
Now why this is, or how I can change it?
f = open('...')
text_file1.write(str(i) + ',' + harvestServer + ',' + finalString + harvestCommand + '\r')
text_file1.close()
Replace the \r with \n, having made sure you open the file in text mode. This will use the native convention for your platform (that is, os.linesep).
Alternatively, open the file in binary mode and use \r\n. This will use the Windows convention no matter where you run your code.
Finally, you can control the newline translation by giving the optional newline argument to open().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With