CSV for Node.js

IssuesGitHub

Sync API

The sync API behave like pure functions. For a given input, it always produce the same output.

Because of its simplicity, this is the recommended approach if you don't need scalability and if your dataset fit in memory.

The module to import is csv/sync. The sync example illustrate its usage.

import assert from "node:assert";
import { generate, parse, transform, stringify } from "csv/sync";

// Run the pipeline
const input = generate({ seed: 1, columns: 2, length: 2 });
const rawRecords = parse(input);
const refinedRecords = transform(rawRecords, (data) =>
  data.map((value) => value.toUpperCase())
);
const output = stringify(refinedRecords);
// Print the final result
assert.equal(output, `OMH,ONKCHHJMJADOA\nD,GEACHIN\n`);

About

The Node.js CSV project is an open source product hosted on GitHub and developed by Adaltas.