I am working on the csv generation. I am seperating values which are seperated by comma(,). If the value in a field contains comma, then it should not seperate the field in excel. So I want to put a escape character there. I am using FasterCsv. So how I can put a escape character. What is the escape character of fastercsv?
Just quote every field (doublequotes by default) and commas inside of them are ignored:
CSV.generate(:col_sep=>',', :quote_char => '"') do |row|
row << ["Quid, quid", "latinum dictum"]
row << ["sit, altum", "viditur."]
end
=> "\"Quid, quid\",latinum dictum\n\"sit, altum\",viditur.\n"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With