-
Notifications
You must be signed in to change notification settings - Fork 123
Add undef: :replace for CSV.open
#129
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
Conversation
|
#90 has been opened for this issue but lacks activity. |
lib/csv.rb
Outdated
| # 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)) |
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.
| file_opts.merge!(undef: options.delete(:undef), replace: options.delete(:replace)) | |
| options.delete(:undef) | |
| options.delete(:replace) |
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 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
Compare
|
Thanks! |
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 ```
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 ```
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 ```
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.