In Ruby CSV, how to write a blank ,, instead of ,"", to a file?
And If you need new empty line just add double nils like: [nil, nil]
Use
data = ["column one",nil,"column three"]
which generates that CSV
first,second,third
column one,,column three
Ruby 2.6 has quote_empty
parameter for the constructor, which can be set to false
.
:quote_empty
When setting a true value, CSV will quote empty values with double quotes. When false, CSV will emit an empty string for an empty field value.