Skip to main content

@std/csv@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
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
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

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.

Interfaces

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
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
RecordWithColumn<C extends string> = string extends C ? Record<string, string | undefined> : Record<C, string>

Record type with column type.

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/parse";
or

Import directly with a jsr specifier

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