Generating fields containing newline with Ruby CSV::Writer
问题 I want to make CSV::Writer generate a line break within a quoted string: A,B,"Line Line",C So that the row would display in Excel as: A,B,Line,C Line Is it possible to prevent CSV:Writer from stripping out newlines? If not, would switching to FasterCSV solve this problem? 回答1: Switching to FasterCSV will work. From an IRB session: require 'fastercsv' FasterCSV.open("./testfile.csv", "w") do |csv| csv << ["row", "of", "CSV\nCSV", "data"] end 回答2: Looks like you can if you set the row separator