Actions
Bug #17430
closedCSV: NoMethodError when the write_nil_value or write_empty_value options are used
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)
Actions
Like0
Like0Like0