[ruby/csv] CSV#read consumes the same lines with other methods like CSV#shift
GitHub: fix https://github.com/ruby/csv/pull/258 Reported by Lhoussaine Ghallou. Thanks!!! https://github.com/ruby/csv/commit/71e6d24e28
This commit is contained in:
parent
a0709d0aae
commit
73c56e06c4
Notes:
git
2023-05-24 16:44:39 +00:00
@ -2592,7 +2592,14 @@ class CSV
|
|||||||
# # Raises IOError (not opened for reading)
|
# # Raises IOError (not opened for reading)
|
||||||
# csv.read
|
# csv.read
|
||||||
def read
|
def read
|
||||||
rows = to_a
|
rows = []
|
||||||
|
enumerator = parser_enumerator
|
||||||
|
begin
|
||||||
|
while true
|
||||||
|
rows << enumerator.next
|
||||||
|
end
|
||||||
|
rescue StopIteration
|
||||||
|
end
|
||||||
if parser.use_headers?
|
if parser.use_headers?
|
||||||
Table.new(rows, headers: parser.headers)
|
Table.new(rows, headers: parser.headers)
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user