Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/trentm/node-csvrow
parse a CSV row string (in node.js)
https://github.com/trentm/node-csvrow
Last synced: about 2 months ago
JSON representation
parse a CSV row string (in node.js)
- Host: GitHub
- URL: https://github.com/trentm/node-csvrow
- Owner: trentm
- License: other
- Created: 2012-08-17T20:42:21.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T13:06:30.000Z (almost 2 years ago)
- Last Synced: 2024-10-23T22:10:20.340Z (2 months ago)
- Language: JavaScript
- Size: 237 KB
- Stars: 13
- Watchers: 3
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
This is a small node module for parsing individual CSV rows. This can be useful
if you have, say, a user-provided string that is a "comma-separated" set of
strings. Simply splitting on commas doesn't quite suffice.It has been a little while, but when I last looked, existing node.js CSV
modules didn't make it straightforward to just parse a single row of CSV data
synchronously.Follow @trentmick
for updates to this module.# Installation
npm install csvrow
This is also a single node.js module (lib/csvrow.js) with no external deps, so
you can alternatively just grab that file.# Usage
Typical parsing as you'd expect:
> var csvrow = require('csvrow');
> csvrow.parse('a,b,c')
[ 'a', 'b', 'c' ]
> csvrow.parse(' a, b,, d')
[ 'a', 'b', '', 'd' ]And the reverse (stringifying):
> csvrow.stringify(['a', 'b', 'c'])
'a,b,c'
> csvrow.stringify(['a', 'space y', 'c'])
'a,"space y",c'`parse` and `stringify` should always cycle to the same value, including with
some weird edge cases. See the test suite and
.There is also a "normalize" function to get rid of spacing and empty columns:
> csvrow.normalize('a, b, , d')
'a,b,d'Note: dropping empty entries might not be what you want. Patches
welcome to make that optional.# Testing
npm test # tests with first node version on the path
# Versioning
The scheme I follow is most succintly described by the bootstrap guys
[here](https://github.com/twitter/bootstrap#versioning).tl;dr: All versions are `..` which will be incremented for
breaking backward compat and major reworks, new features without breaking
change, and bug fixes, respectively.# License
MIT.