-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix line_terminator option #23608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
1468d25
f3deb4e
a1d91a9
8cf3b69
456ec1b
f562d82
a0ba3b3
9897a49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -563,3 +563,20 @@ def test_to_csv_compression(self, compression_only, | |
result = pd.read_csv(path, index_col=0, | ||
compression=read_compression) | ||
tm.assert_frame_equal(result, df) | ||
|
||
|
||
def test_csv_formatter_line_terminator_default(monkeypatch): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rather than this, can you just modify the appropriate tests to pass in ['\n', os.linesep, None] as parameters (we might already have this) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@jreback There isn't an existing test of the The intent of the PR is to ensure that if no When I opened this PR, I was looking at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think this test is necessary and slightly confusing, can you remove. |
||
# see GH #23608 | ||
# ensure default line_terminator used is os.linesep | ||
from pandas.io.formats.csvs import CSVFormatter | ||
df = DataFrame() | ||
|
||
with monkeypatch.context() as m: | ||
m.setattr(os, 'linesep', 'foo') | ||
assert os.linesep == 'foo' | ||
|
||
formatter_with_default = CSVFormatter(df) | ||
BenRussert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert formatter_with_default.line_terminator == os.linesep | ||
|
||
formatter_with_argument = CSVFormatter(df, line_terminator='bar') | ||
assert formatter_with_argument.line_terminator == 'bar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is going to need a doc-string versionchanged, and an update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On closer look, #24290 covered this. In fact, the same PR may have corrected the entire issue as long as the
CSVFormatter
class is always called withline_terminator=None
.I made a minor docs update to reflect that PR, let me know if you had something else in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reference issue is off? in any event, your change looks fine.