@@ -221,6 +221,7 @@ In [1]: data = pd.DataFrame({
221
221
...: })
222
222
223
223
In [2]: # When passing file PATH to to_csv, line_terminator does not work, and csv is saved with '\r\n'.
224
+ ...: # Also, this converts all '\n's in the data to '\r\n'.
224
225
...: data.to_csv("test.csv", index=False, line_terminator='\n')
225
226
226
227
In [3]: with open("test.csv", mode='rb') as f:
@@ -256,7 +257,7 @@ In [3]: with open("test.csv", mode='rb') as f:
256
257
b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n'
257
258
258
259
259
- - On windows , the value of ``os.linesep`` is ``'\r\n'``,
260
+ - On Windows , the value of ``os.linesep`` is ``'\r\n'``,
260
261
so if ``line_terminator`` is not set, ``'\r\n'`` is used for line terminator.
261
262
- Again, it does not affects the value inside the data.
262
263
@@ -274,8 +275,8 @@ In [3]: with open("test.csv", mode='rb') as f:
274
275
b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n'
275
276
276
277
277
- - As default value of ``line_terminator`` changes, just passing file object with ``newline='\n' `` does not set ``'\n'`` to line terminator.
278
- Pass ``line_terminator='\n' `` explicitly.
278
+ - For files objects, specifying ``newline`` is not sufficient to set the line terminator.
279
+ You must pass in the ``line_terminator`` explicitly, even in this case .
279
280
280
281
.. code-block:: ipython
281
282
0 commit comments