Class Index | File Index

Classes


Namespace CSV


Defined in: ucsv-1.1.0.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
CSV
Namespace for CSV functions
Method Summary
Method Attributes Method Name and Description
<inner>  
Converts an array into a Comma Separated Values list.
<inner>  
csvToArray(s, trm)
Converts a Comma Separated Values string into an array of arrays.
Namespace Detail
CSV
Namespace for CSV functions
Method Detail
<inner> {string} arrayToCsv(a)
Converts an array into a Comma Separated Values list. Each item in the array should be an array that represents one line in the CSV. Nulls are interpreted as empty fields.
var csvArray = [
['Leno, Jay', 10],
['Conan "Conando" O\'Brien', '11:35' ],
['Fallon, Jimmy', '12:35' ]
];
CSV.arrayToCsv(csvArray);
// Outputs a string containing:
// "Leno, Jay",10
// "Conan ""Conando"" O'Brien",11:35
// "Fallon, Jimmy",12:35
Parameters:
{String} a
The array to convert
Returns:
A CSV representation of the provided array.

<inner> {Array} csvToArray(s, trm)
Converts a Comma Separated Values string into an array of arrays. Each line in the CSV becomes an array. Empty fields are converted to nulls and non-quoted numbers are converted to integers or floats.
var csv = '"Leno, Jay",10' + "\n" +
'"Conan ""Conando"" O\'Brien",11:35' + "\n" +
'"Fallon, Jimmy",12:35' + "\n";

var array = CSV.csvToArray(csv);

// array is now
// [
// ['Leno, Jay', 10],
// ['Conan "Conando" O\'Brien', '11:35' ],
// ['Fallon, Jimmy', '12:35' ]
// ];
Parameters:
{String} s
The string to convert
{Boolean} trm Optional, Default: false
If set to True leading and trailing whitespace is stripped off of each non-quoted field as it is imported
Returns:
The CSV parsed as an array

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 22 2012 22:37:33 GMT-0800 (PST)