Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd `undef: :replace` for `CSV.open` #129
Merged
Conversation
|
#90 has been opened for this issue but lacks activity. |
lib/csv.rb
Outdated
| @@ -1021,6 +1026,7 @@ def open(filename, mode="r", **options) | |||
| # wrap a File opened with the remaining +args+ with no newline | |||
| # decorator | |||
| file_opts = {universal_newline: false}.merge(options) | |||
| file_opts.merge!(undef: options.delete(:undef), replace: options.delete(:replace)) | |||
kou
Jun 1, 2020
Member
Suggested change
file_opts.merge!(undef: options.delete(:undef), replace: options.delete(:replace))
options.delete(:undef)
options.delete(:replace)
Suggested change
| file_opts.merge!(undef: options.delete(:undef), replace: options.delete(:replace)) | |
| options.delete(:undef) | |
| options.delete(:replace) |
koic
Jun 1, 2020
Author
Contributor
I updated it. Thanks for your review!
I updated it. Thanks for your review!
This PR adds `undef: :replace` option for `CSV.open`. `File.open` has `undef: :replace` option, but `CSV.open` does not. It would be convenient if `CSV.open` could have a shortcut by having `undef: :replace` option.
4c027bf
to
625f721
|
Thanks! |
koic
added a commit
to koic/csv
that referenced
this pull request
Jun 3, 2020
This PR adds `invalid: :replace` for `CSV.open`. It is a PR similar to ruby#129. And this PR uses `String#scrub` to prevent the following `ArgumentError`. ```ruby /[,"]/.match?("\x82\xA0") #=> ArgumentError (invalid byte sequence in UTF-8) /[,"]/.match?("\x82\xA0".scrub) #=> false ```
koic
added a commit
to koic/csv
that referenced
this pull request
Jun 4, 2020
This PR adds `invalid: :replace` for `CSV.open`. It is a PR similar to ruby#129. And this PR uses `String#scrub` to prevent the following `ArgumentError`. ```ruby /[,"]/.match?("\x82\xA0") #=> ArgumentError (invalid byte sequence in UTF-8) /[,"]/.match?("\x82\xA0".scrub) #=> false ```
koic
added a commit
to koic/csv
that referenced
this pull request
Jun 4, 2020
This PR adds `invalid: :replace` for `CSV.open`. It is a PR similar to ruby#129. And this PR uses `String#scrub` to prevent the following `ArgumentError`. ```ruby /[,"]/.match?("\x82\xA0") #=> ArgumentError (invalid byte sequence in UTF-8) /[,"]/.match?("\x82\xA0".scrub) #=> false ```
kou
pushed a commit
that referenced
this pull request
Jun 4, 2020
This PR adds `invalid: :replace` for `CSV.open`. It is a PR similar to #129.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds
undef: :replaceoption forCSV.open.File.openhasundef: :replaceoption, butCSV.opendoes not.It would be convenient if
CSV.opencould have a shortcut by havingundef: :replaceoption.