
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@alesmenzel/csv
Advanced tools
Simple and elegant streaming csv parser.
Handles formats defined by RFC4180 but also works with format produced by PHP's fputcsv. Note in mind, that there is no defacto standard for CSV and different csv libraries create slightly different versions, for example some of them
# this is a comment (see relaxComments and comment options)"\"" (this is valid csv cell in PHP's version, handled by default)"abc" ,"cde" (see relaxCharactersAfterQuotedText option)relaxColumnCount option)bom option)By default we are very strict about parsing the CSV, but can use the relax* rules to lower the bar.
npm i --save @alesmenzel/csv
const createCSVParser = require('@alesmenzel/csv')
const csv = new createCSVParser({
// delimiter: ',' (default)
// quote: '"' (default)
// rowDelimiter: '\n' (default) - handles \r\n as well
// escape: '\\' (default)
// ... and other (see options below)
// ... you can pass Transform stream options here - e.g. highWaterMark
})
const rows = []
csv.on('data', (row) => {
rows.push(row)
})
csv.on('end', () => {
console.log(rows)
})
csv.write('A,B,C\n')
csv.write('a,b,c\n')
csv.end('x,"Joe ""The Death"" Black",z\n')
| Option | Description | Default Value |
|---|---|---|
delimiter | Single character that is used to delimit the cells in a row. | , |
rowDelimiter | Single character that is used to delimit the rows in the input. | \n (optionally preceded by \r) |
quote | Single character that is used to quote the value of a cell. | " |
escape | Single character that is used to escape a character inside the cell. | \ |
comment | Single character that is used to define a comment line. | # |
bom | Strip BOM from the first line of CSV if present. | true |
relaxComments | Allow comments in CSV. Comments are lines that start with the comment character. | false |
relaxCharactersAfterQuotedText | Allow extranious characters after end of quoted cell, but those extra characters are ignored. | false |
relaxComments | Allow comments in CSV. Comments are lines that start with the comment character. | false |
relaxColumnCount | Allow inconsistent column count per each row. | false |
highWaterMark and other transform stream options | Other options are passed to the underlaying Transform stream. | - |
Besides the standard stream events, we emit the following:
"comment" (comment: string)When a comment line is found. The payload is the actual comment string without the comment character (e.g. #).
csv.on('comment', (comment: string) => {
// ...
})
This package is developed under the MIT licence.
FAQs
CSV parser
The npm package @alesmenzel/csv receives a total of 4 weekly downloads. As such, @alesmenzel/csv popularity was classified as not popular.
We found that @alesmenzel/csv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.