parse

converts a CSV string to a Javascript data array

array parse(string text, [object delimiter] );
textstringa CSV string
delimiterobjectthe rows/columns delimiters used during CSV parsing
arraya Javascript array with parsed values

Example

var data = webix.csv.parse("a,b\n,c,d"); // output[[a,b],[c,d]]

Details

The delimiter is an object with the following properties:

var delimiter = {
    rows: "\n", // the rows delimiter
    cols: "\t"  // the columns delimiter
}
  • The default rows delimiter - '\n' (new-line character)
  • The default columns delimiter - '\t' (horizontal tab )
var csv = '1-The Shawshank Redemption|2-The Godfather';
var delimiter = {rows:"|",  cols:"-" };
var data  = webix.csv.parse(csv, delimiter);
//output [["1", "The Shawshank Redemption"], ["2", "The Godfather, "1972"]]


You can change delimiters globally by setting webix.csv.delimiter.rows and webix.csv.delimiter.cols properties.

webix.csv.delimiter.rows = "\b";
webix.csv.delimiter.cols = "\v";
Back to top