New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

csv-streamify

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-streamify - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

cli.js

5

CHANGELOG.md

@@ -0,1 +1,6 @@

0.9.1 / 2014-03-25
==================
* add simple CLI tool
0.9.0 / 2013-12-27

@@ -2,0 +7,0 @@ ==================

5

package.json
{
"name": "csv-streamify",
"version": "0.9.0",
"version": "0.9.1",
"description": "Streaming CSV Parser. Made entirely out of streams.",

@@ -13,2 +13,5 @@ "author": "Clemens Stolle",

},
"bin": {
"csv-streamify": "cli.js"
},
"repository": "https://github.com/klaemo/csv-stream",

@@ -15,0 +18,0 @@ "keywords": [

52

Readme.md

@@ -29,3 +29,2 @@ csv-streamify [![Build Status](https://travis-ci.org/klaemo/csv-stream.png)](https://travis-ci.org/klaemo/csv-stream)

// do stuff with data as it comes in
// Array.isArray(JSON.parse(line)) === true

@@ -41,3 +40,3 @@ // current line number

// doc is an array of row arrays
doc.forEach(function (row) {})
doc.forEach(function (row) { console.log(row) })
}

@@ -49,7 +48,8 @@

```
__Note:__ If you pass a callback to ```csv-stream``` it will buffer the parsed data for you and pass it to the callback when it's done.
__Note:__ If you pass a callback to ```csv-streamify``` it will buffer the parsed data for you and pass it to the callback when it's done. This behaviour can obviously lead to out of memory errors with very large csv files.
### Options
You can pass some options to the parser. All of them are optional. Here are the defaults.
You can pass some options to the parser. **All of them are optional**.
The options are also passed to the underlying transform stream, so you can pass in any standard node core stream options.

@@ -61,17 +61,49 @@

newline: '\n', // newline character (use \r\n for CRLF files)
quote: '\"', // what's considered a quote
quote: '"', // what's considered a quote
empty: '', // empty fields are replaced by this,
inputEncoding: '', // the encoding of the source, if set Iconv will convert it to utf8
objectMode: false, // emit arrays instead of stringified arrays or buffers
columns: false // if set to true, uses first row as keys -> [ { column1: value1, column2: value2 }, ...]
// specify the encoding of the source if it's something other than utf8
inputEncoding: '',
// if true, emit arrays instead of stringified arrays or buffers
objectMode: false,
// if set to true, uses first row as keys -> [ { column1: value1, column2: value2 }, ...]
columns: false
}
```
In order for the inputEncoding option to take effect you need to install [iconv-lite](https://github.com/ashtuchkin/iconv-lite).
In order for the inputEncoding option to take effect you need to install [iconv-lite](https://github.com/ashtuchkin/iconv-lite) (`npm install iconv-lite --save`).
Also, take a look at the iconv-lite documentation for supported encodings.
(iconv-lite provides pure javascript character encoding conversion -> no native code compilation)
## CLI
To use on the command line install it globally:
```bash
$ npm install csv-streamify -g
```
This should add the `csv-streamify` command to your `$PATH`.
Then, you either pipe data into it or give it a filename:
```bash
# pipe data in
$ cat some_data.csv | csv-streamify
# pass a filename
$ csv-streamify some_data.csv > output.json
# tell csv-streamify to read from + wait on stdin
$ csv-streamify -
```
## Wishlist
- browser support
If you would like to contribute either of those just open an issue so we can discuss it further. :)
## Contributors
[Nicolas Hery](https://github.com/nicolashery) (objectMode)
[Nicolas Hery](https://github.com/nicolashery) (objectMode)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc