csv-document
v1.1.2
Published
A library for working with CSV documents
Downloads
4
Readme
CSVDocument
Introduction
CSVDocument is a library for working with CSV documents.
Installation
Install via npm:
npm install csv-document
Parsing
import { CSVDocument } from "csv-document";
const doc = CSVDocument.parse(csvText);
Serializing
const csvText = doc.serialize()
Editing
doc.columns = ["id", "name", "price"];
doc.entries = [
{
id: "0",
name: "Apple",
price: 1,
},
{
id: "1",
name: "Banana",
price: 2,
},
{
id: "2",
id: "Carrot",
price: 3,
},
];
UTF8
const csvText = doc.serialize();
const blob = new Blob([CSVDocument.BOM.UTF8 + csvText]);
CSV Syntax
Strings:
Hello World
Numbers:
123
Number-like strings:
"123"
Strings with delimiters:
"Hello, World"
Strings with quotes:
Quote: "
Strings surrounded by quotes:
"""This string surrounded by quotes"""
License
Licensed under MIT. All files can be used for commercial or non-commercial purposes. Do not resell. Attribution is appreciated but not due.