Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/csv/mod.ts

The Deno Standard Library
Latest
The Standard Library has been moved to JSR. See the blog post for details.
import * as mod from "https://deno.land/std@0.224.0/csv/mod.ts";

Reads and writes comma-separated values (CSV) files.

There are many kinds of CSV files; this module supports the format described in RFC 4180.

A csv file contains zero or more records of one or more fields per record. Each record is separated by the newline character. The final record may optionally be followed by a newline character.

field1,field2,field3

White space is considered part of a field.

Carriage returns before newline characters are silently removed.

Blank lines are ignored. A line with only whitespace characters (excluding the ending newline character) is not considered a blank line.

Fields which start and stop with the quote character " are called quoted-fields. The beginning and ending quote are not part of the field.

The source:

normal string,"quoted-field"

results in the fields

[`normal string`, `quoted-field`]

Within a quoted-field a quote character followed by a second quote character is considered a single quote.

"the ""word"" is true","a ""quoted-field"""

results in

[the "word" is true, a "quoted-field"]

Newlines and commas may be included in a quoted-field

"Multi-line
field","comma is ,"

results in

[`Multi-line
field`, `comma is ,`]

Classes

Read data from a CSV-encoded stream or file. Provides an auto/custom mapper for columns.

Convert each chunk to a CSV record.

A ParseError is returned for parsing errors. Line numbers are 1-indexed and columns are 0-indexed.

Error thrown in stringify.

Functions

Csv parse helper to manipulate data. Provides an auto/custom mapper for columns.

Write data using CSV encoding.

Type Aliases

The most essential aspect of a column is accessing the property holding the data for that column on each object in the data array. If that member is at the top level, Column can simply be a property accessor, which is either a string (if it's a plain object) or a number (if it's an array).

Column information.

An object (plain or array)

Options for parse and CsvParseStream.

Array index or record key corresponding to a value for a data object.

Record type with column type.

Row return type.

Options for stringify.