Skip to main content
Module

x/simple_utility/deps.pure_ext.ts>parse

Simplify processing for Deno.
Go to Latest
function parse
import { parse } from "https://deno.land/x/simple_utility@v2.0.10/deps.pure_ext.ts";

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

Examples

Example 1

import { parse } from "https://deno.land/std@0.224.0/csv/parse.ts";
const string = "a,b,c\nd,e,f";

console.log(
  await parse(string, {
    skipFirstRow: false,
  }),
);
// output:
// [["a", "b", "c"], ["d", "e", "f"]]

Parameters

input: string

Input to parse.

optional
opt: undefined

options of the parser.

Returns

string[][]

If you don't provide opt.skipFirstRow and opt.columns, it returns string[][]. If you provide opt.skipFirstRow or opt.columns, it returns Record<string, unknown>[].

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

Examples

Example 1

import { parse } from "https://deno.land/std@0.224.0/csv/parse.ts";
const string = "a,b,c\nd,e,f";

console.log(
  await parse(string, {
    skipFirstRow: false,
  }),
);
// output:
// [["a", "b", "c"], ["d", "e", "f"]]

Type Parameters

T extends ParseOptions

Parameters

input: string

Input to parse.

opt: T

options of the parser.

Returns

ParseResult<ParseOptions, T>

If you don't provide opt.skipFirstRow and opt.columns, it returns string[][]. If you provide opt.skipFirstRow or opt.columns, it returns Record<string, unknown>[].