toolkit/javascript/d3/src/csv/format.js
changeset 47 c0b4a8b5a012
equal deleted inserted replaced
46:efd9c589177a 47:c0b4a8b5a012
       
     1 d3.csv.format = function(rows) {
       
     2   return rows.map(d3_csv_formatRow).join("\n");
       
     3 };
       
     4 
       
     5 function d3_csv_formatRow(row) {
       
     6   return row.map(d3_csv_formatValue).join(",");
       
     7 }
       
     8 
       
     9 function d3_csv_formatValue(text) {
       
    10   return /[",\n]/.test(text)
       
    11       ? "\"" + text.replace(/\"/g, "\"\"") + "\""
       
    12       : text;
       
    13 }