Skip to content

Commit

Permalink
DOC: applied gfyoung's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
deflatSOCO committed Oct 10, 2018
1 parent 7c6617e commit eeec91c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ In [1]: data = pd.DataFrame({
...: })

In [2]: # When passing file PATH to to_csv, line_terminator does not work, and csv is saved with '\r\n'.
...: # Also, this converts all '\n's in the data to '\r\n'.
...: data.to_csv("test.csv", index=False, line_terminator='\n')

In [3]: with open("test.csv", mode='rb') as f:
Expand Down Expand Up @@ -256,7 +257,7 @@ In [3]: with open("test.csv", mode='rb') as f:
b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n'


- On windows, the value of ``os.linesep`` is ``'\r\n'``,
- On Windows, the value of ``os.linesep`` is ``'\r\n'``,
so if ``line_terminator`` is not set, ``'\r\n'`` is used for line terminator.
- Again, it does not affects the value inside the data.

Expand All @@ -274,8 +275,8 @@ In [3]: with open("test.csv", mode='rb') as f:
b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n'


- As default value of ``line_terminator`` changes, just passing file object with ``newline='\n'`` does not set ``'\n'`` to line terminator.
Pass ``line_terminator='\n'`` explicitly.
- For files objects, specifying ``newline`` is not sufficient to set the line terminator.
You must pass in the ``line_terminator`` explicitly, even in this case.

.. code-block:: ipython

Expand Down

0 comments on commit eeec91c

Please sign in to comment.