You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document pattern matching on parsed CSV rows - #383
doc/csv/recipes/filtering.rdoc isn't a good place for this. "Filtering" in it means a Unix-style filter that reads CSV and writes CSV. Could you move this to doc/csv/recipes/parsing.rdoc and use the "Recipe: ..." heading style like other recipes?
header_converters: :symbol doesn't just convert headers to symbols. It also downcases them and replaces spaces with _. For example, "First Name" is converted to :first_name. So Name: doesn't match even with header_converters: :symbol. Could you describe it? We can also mention that header_converters: ->(header) {header.to_sym} keeps the original case. The comment in lib/csv/row.rb has the same problem.
Could you remove the tests? test_patterns_with_string_headers asserts that a symbol key doesn't match a string header but CSV::Row pattern matching Symbol assumption #246 is still open to discuss changing it. We don't want to fix the current behavior by a test. Other cases are already covered by existing tests. So this can be a document only change.
"This example uses Ruby 3.0 or later, where +in+ returns +true+ or +false+." can be just "This example requires Ruby 3.0 or later."
"Header conversion is opt-in: CSV::Row preserves the header key types supplied by the parser." is redundant. "Headers are strings by default. So a symbol key doesn't match:" is enough.
I’ll move the recipe to the parsing docs and drop the new tests. I’ll also fix both examples to show how the built-in converter turns First Name into :first_name.
Moved the recipe to the parsing docs and removed the added tests. The examples now show both how First Name becomes :first_name and how to keep the original case. The examples and the CSV test suite pass.
This branch has not been deployed
No deployments
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.
Adds a filtering recipe for matching parsed CSV rows by header or position. The header example uses
header_converters: :symbol, as suggested in #246.The examples and both test suites passed on Ruby 3.3.13. I also checked the recipe in the generated docs.