1.0.2 • Published 5 years ago

simple-csv-writer v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

simple-csv-writer

Converts a JavaScript array into a CSV string based on to the RFC 4180 standard.

npm

Usage

simple-csv-writer can be imported as an AMD module or globally as the writecsv function. The first argument must be an array of arrays, where each array is a line and each value of that array is the comma-separated value. The second argument is an optional object that can be used to change the default separator using the separator key (default is ,) and the default line separator using the newLine key (default is \r\n).

This library only serializes the input and does not perform any check on the length of the lines.

import writecsv from "simple-csv-writer";

const data = [
	["1", "simple text"],
	["2", "with \"quotes\""],
	["3", "with separator, and \nnewline"]
];

writecsv(data);
1,simple text
2,"with ""quotes"""
3,"with separator, and 
newline"