csv-document
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

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.

Package Sidebar

Install

npm i csv-document

Weekly Downloads

2

Version

1.1.2

License

MIT

Unpacked Size

16.6 kB

Total Files

6

Last publish

Collaborators

  • cymaera