Skip to main content
Module

std/encoding/csv.ts>ParseOptions

Deno standard library
Go to Latest
interface ParseOptions
implements ReadOptions
import { type ParseOptions } from "https://deno.land/std@0.113.0/encoding/csv.ts";

Properties

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

optional
columns: string[] | ColumnOptions[]

If you provide string[] or ColumnOptions[], those names will be used for header definition.

optional
parse: (input: unknown) => unknown

Parse function for rows. Example:

    import { parse } from "./csv.ts";
    const r = await parse('a,b,c\ne,f,g\n', {
     columns: ["this", "is", "sparta"],
      parse: (_e: unknown) => {
        const e = _e as { this: unknown, is: unknown, sparta: unknown };
        return { super: e.this, street: e.is, fighter: e.sparta };
      }
    });
// output
// [
//   { super: "a", street: "b", fighter: "c" },
//   { super: "e", street: "f", fighter: "g" }
// ]