Skip to main content

@std/csv@0.215.0

latest
Works with
It is unknown whether this package works with Node.js, Deno, Browsers, Cloudflare Workers, Bun
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)

Classes

c
CsvParseStream<T extends CsvParseStreamOptions | undefined = undefined>(options?: T)

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

c
CsvStringifyStream<TOptions extends CsvStringifyStreamOptions>(options?: TOptions)

Convert each chunk to a CSV record.

c
ParseError(
start: number,
line: number,
column: number | null,
message: string
)

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

  • column: number | null

    Column (rune index) where the error occurred

  • line: number

    Line where the error occurred

  • startLine: number

    Line where the record starts

c
StringifyError(message?: string)

Error thrown in stringify.

Functions

f
parse<T extends ParseOptions>(
input: string,
opt?: T
): ParseResult<ParseOptions, T>
2 overloads

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

f
stringify(
data: DataItem[],
unnamed 1?: StringifyOptions
): string

Write data using CSV encoding.

Interfaces

  • columns: readonly string[]

    List of names used for header definition.

  • skipFirstRow: boolean

    If you provide skipFirstRow: true and columns, the first line will be skipped. If you provide skipFirstRow: true but not columns, the first line will be skipped and used as header definitions.

  • columns: Array<string>

    A list of columns to be included in the output.

  • separator: string

    Delimiter used to separate values.

I

Options for parse.

  • columns: readonly string[]

    List of names used for header definition.

  • skipFirstRow: boolean

    If you provide skipFirstRow: true and columns, the first line will be skipped. If you provide skipFirstRow: true but not columns, the first line will be skipped and used as header definitions.

I

Options for parseRecord.

  • comment: string

    Character to start a comment.

  • Enabling checking number of expected fields for each row.

  • lazyQuotes: boolean

    Allow unquoted quote in a quoted field or non-double-quoted quotes in quoted field.

  • separator: string

    Character which separates values.

  • Flag to trim the leading space of the value.

Type Aliases

T
Column = ColumnDetails | PropertyAccessor | PropertyAccessor[]

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).

T
ColumnDetails = { header?: string; prop: PropertyAccessor | PropertyAccessor[]; }

Column information.

  • header: string
    No documentation available
  • prop: PropertyAccessor | PropertyAccessor[]
    No documentation available
T
DataItem = Record<string, unknown> | unknown[]

An object (plain or array)

T
ParseResult<ParseOptions, T> = T extends
ParseOptions
& { columns: readonly (infer C extends string)[]; }
? RecordWithColumn<C>[] : T extends ParseOptions & { skipFirstRow: true; } ? Record<string, string | undefined>[] : T extends
ParseOptions
& { columns?: undefined; skipFirstRow?: false | undefined; }
? string[][] : Record<string, string | undefined>[] | string[][]

Options for parse and CsvParseStream.

T
PropertyAccessor = number | string

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

T
RecordWithColumn<C extends string> = string extends C ? Record<string, string | undefined> : Record<C, string>

Record type with column type.

T
RowType<T> = T extends undefined ? string[] : ParseResult<CsvParseStreamOptions, T>[number]

Row return type.

T
StringifyOptions = { headers?: boolean; separator?: string; columns?: Column[]; bom?: boolean; }

Options for stringify.

  • bom: boolean
    No documentation available
  • columns: Column[]
    No documentation available
  • headers: boolean
    No documentation available
  • separator: string
    No documentation available

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/csv

Import symbol

import * as mod from "@std/csv";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/csv";