diff -r efd9c589177a -r c0b4a8b5a012 toolkit/javascript/d3/src/csv/format.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolkit/javascript/d3/src/csv/format.js Thu Apr 10 14:20:23 2014 +0200 @@ -0,0 +1,13 @@ +d3.csv.format = function(rows) { + return rows.map(d3_csv_formatRow).join("\n"); +}; + +function d3_csv_formatRow(row) { + return row.map(d3_csv_formatValue).join(","); +} + +function d3_csv_formatValue(text) { + return /[",\n]/.test(text) + ? "\"" + text.replace(/\"/g, "\"\"") + "\"" + : text; +}