Closed rytkmt closed 5 months ago
Could you try the latest csv gem?
@kou
It was the same result
Ruby3.2.3 pry(main)> require 'csv'; Tempfile.open { |t| t.write(%|"\n",""\r\n|); t.rewind; CSV.open(t.path, row_sep: "\r\n") { p _1.to_a } }
[["\n", ""]]
=> [["\n", ""]]
Ruby3.2.3 pry(main)> require 'csv'; Tempfile.open { |t| t.write(%|"\n",""\r\n|); t.rewind; CSV.open(t.path, skip_lines: /xxx/, row_sep: "\r\n") { p _1.to_a } }
CSV::MalformedCSVError: Any value after quoted field isn't allowed in line 1.
from /home/vagrant/.rbenv/versions/3.2.3/lib/ruby/3.2.0/csv/parser.rb:1067:in `parse_quotable_robust'
If CSV::VERSION
isn't "3.2.8"
, you're not using the latest csv gem.
@kou Sorry, I was wrong.
but the result was the same.
Ruby3.2.3 pry(main)> require 'csv'; Tempfile.open { |t| t.write(%|"\n",""\r\n|); t.rewind; CSV.open(t.path, row_sep: "\r\n") { p _1.to_a } }
[["\n", ""]]
=> [["\n", ""]]
Ruby3.2.3 pry(main)> require 'csv'; Tempfile.open { |t| t.write(%|"\n",""\r\n|); t.rewind; CSV.open(t.path, skip_lines: /xxx/, row_sep: "\r\n") { p _1.to_a } }
CSV::MalformedCSVError: Any value after quoted field isn't allowed in line 1.
from /home/vagrant/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/csv-3.2.8/lib/csv/parser.rb:1066:in `parse_quotable_robust'
Ruby3.2.3 pry(main)> CSV::VERSION
=> "3.2.8"
Thanks for checking.
I've fixed this and released 3.2.9. Could you try it?
@kou Sorry for the late confirmation. I can confirm that it works properly. Thank you for your quick response.
If skip_lines is not specified
If specifying skip_lines that does not affect reading
Probably CSV::Parser#skip_needless_lines is the cause