source: Dev/trunk/d3/src/csv/format.js @ 76

Last change on this file since 76 was 76, checked in by fpvanagthoven, 14 years ago

d3

File size: 300 bytes
Line 
1d3.csv.format = function(rows) {
2  return rows.map(d3_csv_formatRow).join("\n");
3};
4
5function d3_csv_formatRow(row) {
6  return row.map(d3_csv_formatValue).join(",");
7}
8
9function d3_csv_formatValue(text) {
10  return /[",\n]/.test(text)
11      ? "\"" + text.replace(/\"/g, "\"\"") + "\""
12      : text;
13}
Note: See TracBrowser for help on using the repository browser.