Skip to content
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

docs: Add entry for backslash_quotes liberal parsing #280

Merged
merged 1 commit into from
May 31, 2023

Conversation

markaschneider
Copy link
Contributor

No description provided.


With +liberal_parsing+ and its +backslash_quote+ sub-option:
ary = CSV.parse_line(str, liberal_parsing: { backslash_quotes: true })
ary # => ["Show", "Harold \"Handcuff\" Houdini", "Tampa Theater"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the result is incorrect.
Could you check this again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kou Thanks for catching that. I thought I had copied and pasted, but apparently not. backslash_quotes: true should be backslash_quote: true. I'll resubmit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a console log:

 ~/code/csv/doc/csv/options/parsing git:(doc/add-liberal-parsing) docker run -it 1e6b2a26f38d bash
root@d277469b2d78:/# irb
irb(main):001:0> require 'csv'
=> true

irb(main):002:0> RUBY_VERSION
=> "3.2.0"

irb(main):003:0> str = 'Show,"Harry \"Handcuff\" Houdini, the one and only","Tampa Theater"'
=> "Show,\"Harry \\\"Handcuff\\\" Houdini, the one and only\",\"Tampa Theater\""

irb(main):004:0> ary = CSV.parse_line(str, liberal_parsing: true)
=> ["Show", "\"Harry \\\"Handcuff\\\" Houdini", " the one and only\"", "Tampa Theater"]

irb(main):005:0> puts ary[1]
"Harry \"Handcuff\" Houdini
=> nil

irb(main):006:0>

irb(main):007:0> ary = CSV.parse_line(str, liberal_parsing: { backslash_quote: true })
=> ["Show", "Harry \"Handcuff\" Houdini, the one and only", "Tampa Theater"]

irb(main):008:0> puts ary[1]
Harry "Handcuff" Houdini, the one and only
=> nil

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update the results?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. I resubmitted just now.

@markaschneider markaschneider force-pushed the doc/add-liberal-parsing branch from f5e3a8b to 43feb3a Compare May 18, 2023 00:44
@markaschneider markaschneider force-pushed the doc/add-liberal-parsing branch from 43feb3a to b6b4627 Compare May 31, 2023 02:21
@kou kou merged commit 0dcfcd9 into ruby:master May 31, 2023
@kou
Copy link
Member

kou commented May 31, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants