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
The path is correct, the proof is that the former issue with #read is not happening anymore.
I'm running the code with : bundle exec ruby main.rb
Ruby version : 3.1.2p20
Steps to reproduce the issue :
Open a csv file with CSV.open('file.csv')
Call #pos on it, it returns 0
Call #eof? on it, it returns false
Call #each, #map, or #filter on it
Call #pos on it, it returns the last position
Call #eof? on it, it returns false when it should be true
main.rb
require 'csv'
# it returns true on the second call of #eof? as expected only if
# I comment the 4th line, starting from the line below this
puts 'csv'
csv = CSV.open('event_attendees.csv')
puts "pos : #{csv.pos}" # expecting 0, getting 0
puts "eof? : #{csv.eof?}" # expecting false, getting false
csv.each { |row| row }
puts "pos : #{csv.pos}" # expecting 1814, getting 1814
puts "eof? : #{csv.eof?}" # expecting true, getting false
puts
# no issue when using File.open
puts 'File'
file = File.open('event_attendees.csv')
puts "pos : #{file.pos}" # expecting 0, getting 0
puts "eof? : #{file.eof?}" # expecting false, getting false
file.each { |row| row }
puts "pos : #{file.pos}" # expecting 1814, getting 1814
puts "eof? : #{file.eof?}" # expecting true, getting true
This is almost the same bug I mentioned in this issue #258 (which got fixed), but instead of reading the file with #read, I'm using the #each method on the csv file, #map and #filter also cause the issue.
…ther methods
This may have a performance penalty. We should benchmark this.
GitHub: fixruby/csv#260
Reported by Lhoussaine Ghallou. Thanks!!!
ruby/csv@acc05116c5
nobu
pushed a commit
to nobu/ruby
that referenced
this issue
May 24, 2023
…ther methods
This may have a performance penalty. We should benchmark this.
GitHub: fixruby/csv#260
Reported by Lhoussaine Ghallou. Thanks!!!
ruby/csv@acc05116c5
nobu
pushed a commit
to ruby/ruby
that referenced
this issue
May 24, 2023
…ther methods
This may have a performance penalty. We should benchmark this.
GitHub: fixruby/csv#260
Reported by Lhoussaine Ghallou. Thanks!!!
ruby/csv@acc05116c5
For reference : I cloned this repository on my local machine, then in my Gemfile I put :
The path is correct, the proof is that the former issue with #read is not happening anymore.
I'm running the code with :
bundle exec ruby main.rb
Ruby version : 3.1.2p20
Steps to reproduce the issue :
main.rb
This is almost the same bug I mentioned in this issue #258 (which got fixed), but instead of reading the file with #read, I'm using the #each method on the csv file, #map and #filter also cause the issue.
event_attendees.csv
The text was updated successfully, but these errors were encountered: