New `comment_no_infix` option.
By wdavidw | August 25th, 2023
Version 5.5.0 of csv-parse include the new [`comment_no_infix` option](/parse/options/comment_no_infix/). When activate, comments may only start at the begining of a line.
This is a full-featured CSV parsing tool running entirely on your browser. No data leave your computer ! Use it also to learn how to use our packages and to test the various options interactively.
By wdavidw | August 25th, 2023
Version 5.5.0 of csv-parse include the new [`comment_no_infix` option](/parse/options/comment_no_infix/). When activate, comments may only start at the begining of a line.
By wdavidw | November 13th, 2021
Version 6 of the csv package for Node.js is released along its sub projects. Read about the new features and the breaking changes (fr) introduced by this new version.
By wdavidw | August 27th, 2021
A few weeks ago, we migrated the 5 repositories in one Git monorepo. If interested in the details, read our article on how we merged the repositories while preserving the commit history.
By wdavidw | January 15th, 2019
We just published a new conversion tool which takes a CSV input and convert it to JSON. Use it as a playground to learn how to use our packages, test your options interactively or as a full-featured CSV parsing tool.
By wdavidw | December 5th, 2018
Casting user functions are now called with a context object. The initial properties are "column", "header", "index", "records".
By wdavidw | November 21th, 2018
Version 5.0.0 includes the latest csv-parse and csv-stringify respectively with version 4.0.1 and 5.0.0.
By wdavidw | November 21th, 2018
Version 5.0.0 introduces the new quoted_match
option and support options written both in the underscore and camelcase forms. Some options were renamed. Thus rowDelimiter
is now record_delimiter
and formatters
is now cast
. Read the changelog!
By wdavidw | November 19th, 2018
Version 4.0.0 is a complete re-writing of the project focusing on performance. It also comes with new functionalities as well as some cleanup in the option properties and the exported information. The official website is updated and the changelog contains the list of changes for this major release. Learn more!
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
D,GEACHIN
`);
// Import the package
import * as csv from 'csv';
// Run the pipeline
csv
// Generate 20 records
.generate({
delimiter: '|',
length: 20
})
// Transform CSV data into records
.pipe(csv.parse({
delimiter: '|'
}))
// Transform each value into uppercase
.pipe(csv.transform((record) =>
record.map((value) =>
value.toUpperCase()
)
))
// Convert objects into a stream
.pipe(csv.stringify({
quoted: true
}))
// Print the CSV stream to stdout
.pipe(process.stdout);