UNPKG

faster-csv

Version:

Minimal dependency, fast CSV parser and formatter using modern Node.js APIs.

52 lines (33 loc) 885 B
# faster-csv > Minimal dependency, fast CSV parser and formatter using modern Node.js APIs. ## Installation ```bash npm install faster-csv ```` ## Usage ### Parse CSV ```ts import { parseCSV } from "faster-csv"; for await (const row of parseCSV("data.csv")) { console.log(row); } ``` ### Format CSV ```ts import { formatCSV } from "faster-csv"; await formatCSV("out.csv", [ { name: "Alice", age: 30 }, { name: "Bob", age: 25 } ]); ``` ## API ### `parseCSV(path, options?)` * `headers: boolean` (default: `true`) * `separator: string` (default: `","`) Yields either an array of values or an object if headers are enabled. ### `formatCSV(path, rows, options?)` * `headers: boolean` (default: `true`) * `separator: string` (default: `","`) Writes an array of rows to a CSV file. ## License MIT © Abhimanyu Singh