docs(csv): add module docs (#5157)

This commit is contained in:
Asher Gomez 2024-06-27 15:52:13 +10:00 committed by GitHub
parent 1b092bf12a
commit 162e000be8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,19 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
/** Reads and writes comma-separated values (CSV) files.
/**
* Reads and writes comma-separated values (CSV) files.
*
* ```ts
* import { parse } from "@std/csv/parse";
* import { assertEquals } from "@std/assert/assert-equals";
*
* const string = "a,b,c\nd,e,f";
*
* assertEquals(parse(string, { skipFirstRow: false }), [["a", "b", "c"], ["d", "e", "f"]]);
* assertEquals(parse(string, { skipFirstRow: true }), [{ a: "d", b: "e", c: "f" }]);
* assertEquals(parse(string, { columns: ["x", "y", "z"] }), [{ x: "a", y: "b", z: "c" }, { x: "d", y: "e", z: "f" }]);
* ```
*
* There are many kinds of CSV files; this module supports the format described
* in {@link https://www.rfc-editor.org/rfc/rfc4180.html | RFC 4180}.