-
-
Notifications
You must be signed in to change notification settings - Fork 19k
API: read_csv, to_csv line_terminator keyword inconsistency #35399
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
30c9b83
add values.dtype.kind==f branch to array_with_unit_datetime
arw2019 2f25460
merge with master
arw2019 572363a
revert pandas/_libs/tslib.pyx
arw2019 b891030
merge with master
arw2019 ecd8ce3
merge with master
arw2019 ee55191
merge with master
arw2019 292fcdc
merge with master
arw2019 9e4ac71
Merge remote-tracking branch 'upstream/master'
arw2019 1d0ba61
merge with master
arw2019 b59831e
Merge branch 'master' of https://github.com/arw2019/pandas
arw2019 b954874
Merge remote-tracking branch 'upstream/master'
arw2019 ac0a7f1
merge with master
arw2019 bc55716
added line_terminator arg to read_csv
arw2019 ee69a76
added line_terminator, lineterminator args + tests
arw2019 4d00fea
merge with master
arw2019 c015da5
Merge remote-tracking branch 'upstream/master'
arw2019 73d6d11
fix csv api using kwargs
arw2019 1a6497f
TST: remove failing test - read_csv takes kwargs now
arw2019 3a88ef0
add space between kwargs and colon in docstring
arw2019 7fe8274
DOC: remove the semicolon after kwargs
arw2019 1c27b2c
added line_terminator arg to read_csv
arw2019 1912aa2
added line_terminator, lineterminator args + tests
arw2019 f54df81
fix csv api using kwargs
arw2019 cea28d8
TST: remove failing test - read_csv takes kwargs now
arw2019 85ddf44
add space between kwargs and colon in docstring
arw2019 a28657c
DOC: remove the semicolon after kwargs
arw2019 2b1333f
Merge branch 'csv-api' of https://github.com/arw2019/pandas into csv-api
arw2019 0786617
merge with master
arw2019 5e87bbc
small changes to docstrings
arw2019 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -579,6 +579,7 @@ def read_csv( | |
compression="infer", | ||
thousands=None, | ||
decimal: str = ".", | ||
line_terminator=None, | ||
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. again, in the signature, I think we should only have the one parameter and the compatibility keyword accepted though **kwargs |
||
lineterminator=None, | ||
quotechar='"', | ||
quoting=csv.QUOTE_MINIMAL, | ||
|
@@ -643,7 +644,7 @@ def read_csv( | |
quotechar=quotechar, | ||
quoting=quoting, | ||
skipinitialspace=skipinitialspace, | ||
lineterminator=lineterminator, | ||
lineterminator=lineterminator or line_terminator, # GH 9568 | ||
header=header, | ||
index_col=index_col, | ||
names=names, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
hmm, this signature is displayed in the documentation so doing it like this could be confusing. (also this function is not kwargs only, so although bonkers, passing arguments as positional arguments would break)
maybe add a **kwargs at the end and document as 'for compatbility with csv module'
then in code something like
kwargs.setdefault('lineterminator', line_terminator)
and pass on kwargs instead of line_terminator to CSVFormatter which just passes them onto csvlib.writerUh oh!
There was an error while loading. Please reload this page.
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.
Sounds good! I implemented this idea and added optional kwargs to the docstrings.
In
to_csv
it's maybe a little awkwardbecause we have to feed
line_terminator
toCSVFormatter
but also we want to keepline_terminator
explicit for the docs. It works but I'm happy to write this another way if these lines look odd