From: "kou (Kouhei Sutou) via ruby-core" Date: 2023-02-02T21:07:39+00:00 Subject: [ruby-core:112190] [Ruby master Bug#19402] CSV skip_lines option not behaving as documented Issue #19402 has been updated by kou (Kouhei Sutou). Status changed from Open to Third Party's Issue Assignee set to kou (Kouhei Sutou) It's intentional. `String` `skip_lines:` value is matched as-is. (You can't use special characters such as `^`.) If you have further discussion including how to improve the current documentation, could you report this to upstream? https://github.com/ruby/csv ---------------------------------------- Bug #19402: CSV skip_lines option not behaving as documented https://bugs.ruby-lang.org/issues/19402#change-101625 * Author: jamie_ca (Jamie Macey) * Status: Third Party's Issue * Priority: Normal * Assignee: kou (Kouhei Sutou) * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-darwin21] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- The [CSV documentation](https://ruby-doc.org/stdlib-3.1.0/libdoc/csv/rdoc/CSV.html#class-CSV-label-Option+skip_lines) for the `skip_lines` parser option says "If a String, converts it to a Regexp, ignores lines that match it." Application behaviour as well as [the source](https://github.com/ruby/csv/blob/master/lib/csv/parser.rb#L909-L919) appears to be normalizing the string encoding and running a simple substring check instead. Given the existing behaviour, this might just want a documentation update to describe it accurately? I stumbled across this on a project still on ruby 2.6.9 ([2.6 docs](https://ruby-doc.org/stdlib-2.6.1/libdoc/csv/rdoc/CSV.html#method-c-new)), but it's applicable still at 3.2.0. Reproduction script: ```ruby require 'csv' data = <