Project

General

Profile

Actions

Bug #17430

closed

CSV: NoMethodError when the write_nil_value or write_empty_value options are used

Bug #17430: CSV: NoMethodError when the write_nil_value or write_empty_value options are used

Added by Soilent (Konstantin x) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
[ruby-core:101644]

Description

CSV.generate_line throws an exception when I specify write_nil_value or write_nil_value.

> CSV.generate_line [1,nil,3]
=> "1,,3\n"
> CSV.generate_line [1,nil,3], write_nil_value: 'x'
Traceback (most recent call last):
       12: from /usr/bin/irb:23:in `<main>'
       11: from /usr/bin/irb:23:in `load'
       10: from /usr/lib/ruby/gems/2.7.0/gems/irb-1.2.7/exe/irb:11:in `<top (required)>'
        9: from (irb):3
        8: from (irb):4:in `rescue in irb_binding'
        7: from /usr/lib/ruby/2.7.0/csv.rb:569:in `generate_line'
        6: from /usr/lib/ruby/2.7.0/csv.rb:1230:in `<<'
        5: from /usr/lib/ruby/2.7.0/csv/writer.rb:44:in `<<'
        4: from /usr/lib/ruby/2.7.0/csv/fields_converter.rb:50:in `convert'
        3: from /usr/lib/ruby/2.7.0/csv/fields_converter.rb:50:in `with_index'
        2: from /usr/lib/ruby/2.7.0/csv/fields_converter.rb:50:in `collect'
        1: from /usr/lib/ruby/2.7.0/csv/fields_converter.rb:53:in `block in convert'
NoMethodError (undefined method `empty?' for 1:Integer)
> CSV.generate_line [1,nil,3], write_empty_value: 'x'
NoMethodError (undefined method `empty?' for 1:Integer)

Updated by kou (Kouhei Sutou) almost 5 years ago Actions #1 [ruby-core:101645]

  • Status changed from Open to Closed
  • Assignee set to kou (Kouhei Sutou)

It has been fixed in the latest csv gem.

You can use update your csv by gem install csv.

Updated by Soilent (Konstantin x) almost 5 years ago Actions #2 [ruby-core:101666]

kou (Kouhei Sutou) wrote in #note-1:

It has been fixed in the latest csv gem.

You can use update your csv by gem install csv.

Thank you!

Actions

Also available in: PDF Atom