Git Product home page Git Product logo

csv-parser's Introduction

csv-parser

tests cover size

Streaming CSV parser that aims for maximum speed as well as compatibility with the csv-spectrum CSV acid test suite.

csv-parser can convert CSV into JSON at at rate of around 90,000 rows per second. Performance varies with the data used; try bin/bench.js <your file> to benchmark your data.

csv-parser can be used in the browser with browserify.

neat-csv can be used if a Promise based interface to csv-parser is needed.

Note: This module requires Node v8.16.0 or higher.

Benchmarks

⚡️ csv-parser is greased-lightning fast

→ npm run bench

  Filename                 Rows Parsed  Duration
  backtick.csv                       2     3.5ms
  bad-data.csv                       3    0.55ms
  basic.csv                          1    0.26ms
  comma-in-quote.csv                 1    0.29ms
  comment.csv                        2    0.40ms
  empty-columns.csv                  1    0.40ms
  escape-quotes.csv                  3    0.38ms
  geojson.csv                        3    0.46ms
  large-dataset.csv               7268      73ms
  newlines.csv                       3    0.35ms
  no-headers.csv                     3    0.26ms
  option-comment.csv                 2    0.24ms
  option-escape.csv                  3    0.25ms
  option-maxRowBytes.csv          4577      39ms
  option-newline.csv                 0    0.47ms
  option-quote-escape.csv            3    0.33ms
  option-quote-many.csv              3    0.38ms
  option-quote.csv                   2    0.22ms
  quotes+newlines.csv                3    0.20ms
  strict.csv                         3    0.22ms
  latin.csv                          2    0.38ms
  mac-newlines.csv                   2    0.28ms
  utf16-big.csv                      2    0.33ms
  utf16.csv                          2    0.26ms
  utf8.csv                           2    0.24ms

Install

Using npm:

$ npm install csv-parser

Using yarn:

$ yarn add csv-parser

Usage

To use the module, create a readable stream to a desired CSV file, instantiate csv, and pipe the stream to csv.

Suppose you have a CSV file data.csv which contains the data:

NAME,AGE
Daffy Duck,24
Bugs Bunny,22

It could then be parsed, and results shown like so:

const csv = require('csv-parser')
const fs = require('fs')
const results = [];

fs.createReadStream('data.csv')
  .pipe(csv())
  .on('data', (data) => results.push(data))
  .on('end', () => {
    console.log(results);
    // [
    //   { NAME: 'Daffy Duck', AGE: '24' },
    //   { NAME: 'Bugs Bunny', AGE: '22' }
    // ]
  });

To specify options for csv, pass an object argument to the function. For example:

csv({ separator: '\t' });

API

csv([options | headers])

Returns: Array[Object]

options

Type: Object

As an alternative to passing an options object, you may pass an Array[String] which specifies the headers to use. For example:

csv(['Name', 'Age']);

If you need to specify options and headers, please use the the object notation with the headers property as shown below.

escape

Type: String
Default: "

A single-character string used to specify the character used to escape strings in a CSV row.

headers

Type: Array[String] | Boolean

Specifies the headers to use. Headers define the property key for each value in a CSV row. If no headers option is provided, csv-parser will use the first line in a CSV file as the header specification.

If false, specifies that the first row in a data file does not contain headers, and instructs the parser to use the column index as the key for each column. Using headers: false with the same data.csv example from above would yield:

[
  { '0': 'Daffy Duck', '1': 24 },
  { '0': 'Bugs Bunny', '1': 22 }
]

Note: If using the headers for an operation on a file which contains headers on the first line, specify skipLines: 1 to skip over the row, or the headers row will appear as normal row data. Alternatively, use the mapHeaders option to manipulate existing headers in that scenario.

mapHeaders

Type: Function

A function that can be used to modify the values of each header. Return a String to modify the header. Return null to remove the header, and it's column, from the results.

csv({
  mapHeaders: ({ header, index }) => header.toLowerCase()
})
Parameters

header String The current column header.
index Number The current column index.

mapValues

Type: Function

A function that can be used to modify the content of each column. The return value will replace the current column content.

csv({
  mapValues: ({ header, index, value }) => value.toLowerCase()
})
Parameters

header String The current column header.
index Number The current column index.
value String The current column value (or content).

newline

Type: String
Default: \n

Specifies a single-character string to denote the end of a line in a CSV file.

quote

Type: String
Default: "

Specifies a single-character string to denote a quoted string.

raw

Type: Boolean

If true, instructs the parser not to decode UTF-8 strings.

separator

Type: String
Default: ,

Specifies a single-character string to use as the column separator for each row.

skipComments

Type: Boolean | String
Default: false

Instructs the parser to ignore lines which represent comments in a CSV file. Since there is no specification that dictates what a CSV comment looks like, comments should be considered non-standard. The "most common" character used to signify a comment in a CSV file is "#". If this option is set to true, lines which begin with # will be skipped. If a custom character is needed to denote a commented line, this option may be set to a string which represents the leading character(s) signifying a comment line.

skipLines

Type: Number
Default: 0

Specifies the number of lines at the beginning of a data file that the parser should skip over, prior to parsing headers.

maxRowBytes

Type: Number
Default: Number.MAX_SAFE_INTEGER

Maximum number of bytes per row. An error is thrown if a line exeeds this value. The default value is on 8 peta byte.

strict

Type: Boolean
Default: false

If true, instructs the parser that the number of columns in each row must match the number of headers specified or throws an exception. if false: the headers are mapped to the column index less columns: any missing column in the middle will result in a wrong property mapping! more columns: the aditional columns will create a "_"+index properties - eg. "_10":"value"

Events

The following events are emitted during parsing:

data

Emitted for each row of data parsed with the notable exception of the header row. Please see Usage for an example.

headers

Emitted after the header row is parsed. The first parameter of the event callback is an Array[String] containing the header names.

fs.createReadStream('data.csv')
  .pipe(csv())
  .on('headers', (headers) => {
    console.log(`First header: ${headers[0]}`)
  })

Readable Stream Events

Events available on Node built-in Readable Streams are also emitted. The end event should be used to detect the end of parsing.

CLI

This module also provides a CLI which will convert CSV to newline-delimited JSON. The following CLI flags can be used to control how input is parsed:

Usage: csv-parser [filename?] [options]

  --escape,-e         Set the escape character (defaults to quote value)
  --headers,-h        Explicitly specify csv headers as a comma separated list
  --help              Show this help
  --output,-o         Set output file. Defaults to stdout
  --quote,-q          Set the quote character ('"' by default)
  --remove            Remove columns from output by header name
  --separator,-s      Set the separator character ("," by default)
  --skipComments,-c   Skip CSV comments that begin with '#'. Set a value to change the comment character.
  --skipLines,-l      Set the number of lines to skip to before parsing headers
  --strict            Require column length match headers length
  --version,-v        Print out the installed version

For example; to parse a TSV file:

cat data.tsv | csv-parser -s $'\t'

Encoding

Users may encounter issues with the encoding of a CSV file. Transcoding the source stream can be done neatly with a modules such as:

Or native iconv if part of a pipeline.

Byte Order Marks

Some CSV files may be generated with, or contain a leading Byte Order Mark. This may cause issues parsing headers and/or data from your file. From Wikipedia:

The Unicode Standard permits the BOM in UTF-8, but does not require nor recommend its use. Byte order has no meaning in UTF-8.

To use this module with a file containing a BOM, please use a module like strip-bom-stream in your pipeline:

const fs = require('fs');

const csv = require('csv-parser');
const stripBom = require('strip-bom-stream');

fs.createReadStream('data.csv')
  .pipe(stripBom())
  .pipe(csv())
  ...

When using the CLI, the BOM can be removed by first running:

$ sed $'s/\xEF\xBB\xBF//g' data.csv

Meta

CONTRIBUTING

LICENSE (MIT)

csv-parser's People

Contributors

aheissenberger avatar bendingbender avatar bibhas2 avatar bjdooi avatar chriscarpenter12 avatar emilbayes avatar finnp avatar gaga-change avatar galenandrew avatar gobie avatar gpichot avatar hmalphettes avatar jasnell avatar junosuarez avatar mafintosh avatar max-mapper avatar menkveldj avatar reinaldorauch avatar richardhinkamp avatar risseraka avatar shellscape avatar simonsimcity avatar sindresorhus avatar sylvainleroux avatar timhudson avatar trott avatar trysound avatar tuizi avatar yoshuawuyts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csv-parser's Issues

Determine ridiculously long columns or rows

I'm importing up to 100 MB of data using this library and I had the following use-case:

Since I didn't know which escape- or quote character the file had which I'm getting from a customer on a frequent basis, I set this to null in the configuration - which I thought - would never appear. I thought this would affectively remove this feature of quoting and escaping.

As Fortuna decided to hit me hard today, I got hands on a file where the first character is a null-byte.

Long story short: This library tried to put all the 100 MB file into the first column and the rest of my script pushed for inserting it into the database. The BSON parser for my MongoDB fell face down by this amount of data stating Attempt to write outside buffer bounds at Buffer.write (buffer.js:881:13) at serializeObject [...].

As MongoDB anyways has a limit of 16MB per document, I would like this library to be able to catch a ridiculous data-set like this even before it attempts to load all the data into memory, parse it through my validators and finally let the database (or it's parser) crash.

Would it take long time to implement a double-check mechanism which throws an error if the data, read for a single row or column, exceeds a configured amount of bytes or characters?

Option to skip first line when using "headers" option

I have a CSV file with very descriptive column headers, e.g. "First Name", "Country of Residence", etc, so I use the "headers" option to the csv() constructor to specify shorter names, e.g. "first" and "country". However, doing so causes the first line to be emitted as actual data. Can we add a "skipFirstLine" option to prevent this?

Support multi-byte newlines

Right now there is no way to support non standard multi-byte line endings because newline is treated as only a single character.

CSV with utf-16le not parse properly

Hi there,

I totally hate encodings. I had a csv in utf16-le, that produced weird output when piping it into csv-parser (like \u0000o\u0000r\u0000 \u0000t\u0000h\u0000e\u0000). I could solve it by encoding the file to utf-8. However maybe there is a way that it will also work for this encoding. I will look into this.

Best,
Finn

Reread csv on 'end'

How do I reread the csv file on the 'end' function?

fs.createReadStream('data.csv')
    .pipe(stream)
    .on('data', function (data) {
    //do something
    }).on('end', function () {
    //How do I reread the csv again
    });

Support for newline characters inside column

Hey folks,

Noticed I couldn't use csv-parser when parsing a file that looks like this:

"col1","col2"
"hello","Hey, this is a longe string that has\na few new lines in it\n."

Not sure if it's truly valid CSV, but in my experience – it's common practice.

Is there a way to go around this somehow? If not – I may have to modify csv-parser to support this.

Not consuming all of output triggers fatal error

$ echo "a
1
2" | csv-parser | head -n 1
{"a":"1"}
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at exports._errnoException (util.js:1026:11)
    at WriteWrap.afterWrite (net.js:799:14)

Not consuming the entire input seems to trigger an error.

[README.md] Missing comma in sample code

In README.md you are missing a comma after the newline: '\n' in the block:

var stream = csv({
raw: false, // do not decode to utf-8 strings
separator: ',', // specify optional cell separator
newline: '\n' // specify a newline character
headers: ['index', 'message'] // Specifing the headers
})

Files with absurdly long rows eat up CPU for 14+ hours

I know this is kinda silly, but we basically got DOS'd by csv-parser last night.

We use csv-parser for reading whatever CSV files get uploaded to us. One such file was malformed so that it only had two lines. They forgot to include newline separators between rows of data. Line 1 was a header with 3 columns. Line 2 was 800mb of text.

Making things worse, we pipe the contents into csv-parser from the network. They seem to come in 1000 byte packets. It looks like _transform is adding the packet to buf. To make the problem clear, once it gets to 400mb in the buf, it is going to allocate and deallocate 400+mb about 400,000 times.

I will try to create a PR if I have time, but wanted to get this ticket out there since it's a DOS vulnerability and somewhat hard to protect against without modifications to the library.

Last header field gets double-quoted (unexpected)

Using 1.12.0 here, seeing a weird issue. If to project this problem on the sample:

var csv = require('csv-parser')
var fs = require('fs')

fs.createReadStream('some-csv-file.csv')
  .pipe(csv())
  .on('data', function (data) {
    console.log('Name: %s Age: %s', data.NAME, data.AGE)
  })

if AGE is the last header field, it's not possible to access it via data.AGE, but it is possible to access it via data['"AGE"']. What's more interesting is that it happens only with the last header field. So, as a workaround it's possible to add a comma at the end of the header field (which adds a new, zero-length header field). This gets data.AGE (or data['AGE']) to return the expected value.

Anyone else seen this issue?

CVS parsing stops before end of the file with 1.9.0

Reproduced easily with a CSV from government:
http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.csv

var csv   = require('csv-parser')
var fs    = require('fs')
var file  = 'all_month.csv'
var count = 0;

fs.createReadStream(file).pipe(csv())
    .on('data', () => count++)
    .on('finish', () => console.log(count));

With 1.8.0: 7303 line read (all of them)
With 1.9.0: 5190 line read

This is a huge issue guys. I cannot investigate right now but you should really add big CSV files to your test suite.

Support of text field with one char like " or \" is breaking the parser.

I am using command line csv-parser and the csv file that I am processing is not converted in full, it is stopping in the middle, by looking at the fields, one has normal double quote in (") embedded in the text area (" exactly), I have removed it for test purpose, and now csv-parser goes through all records. This cannot be the final solution for me, as I have other records like this.

I created the below test file which is showing the same issue.

test.csv:

"Field1","Field2","Field3","Field4"
"UN","DEUX","TROIS","QUATRE"
"ONE","T\"WO","THREE","FOUR"
"ABC","DEF","GHI","JKL"
c:>csv-parser test.csv
{"Field1":"UN","Field2":"DEUX","Field3":"TROIS","Field4":"QUATRE"}
{"Field1":"ONE","Field2":"T\\\"WO","Field3":"THREE","Field4":"FOUR\"\r\n\"ABC"}

We are missing the 3rd record, something happened with record 2 and 3 been merged, see ABC is inside record 2.

thanks.

how to skip processing of other events like data?

Hi ,
I have a code which make use of csv-parser and validates the csv file. I'm not using the strict:true option. I'm checking some checks with the headers(like valid headers which my application expects) and parse data in data event etc. However, Can you please let me know how to skip processing data event when I see some error in "header" event?

Ex: fileStream.pipe(csv()) .on('headers', (headers) => { }). on('data',(data) => { }). on('end', () => { });

data format

I see this:

Row {
  ' Time': '0.0500',
  ' Lateral Position': '8.25',
  ' Sagittal Position': '-14.91',
  ' Twisting Position': '-7',
  ' Lateral Velocity': '7.66',
  ' Sagittal Velocity': '1.96',
  ' Twisting Velocity': '0.33',
  ' Lateral Acceleration': '82.13',
  ' Sagittal Acceleration': '24.14',
  ' Twisting Acceleration': '22.79' }

why not this:

Row {
  'Time': '0.0500',
  'Lateral Position': '8.25',
  'Sagittal Position': '-14.91',
  'Twisting Position': '-7',
  'Lateral Velocity': '7.66',
  'Sagittal Velocity': '1.96',
  'Twisting Velocity': '0.33',
  'Lateral Acceleration': '82.13',
  'Sagittal Acceleration': '24.14',
  'Twisting Acceleration': '22.79' }

it must because the data I am feeding you is bad right? duh

Trim whitespace in csv headers

Sometimes the headers include whitespace like

a, b , c,  d
1, 2 ,3 , 4

In these cases they shouldn't be parsed as ' b' but be ' b'.trim() instead.

Parsing is not correct ( with special string )

Here is example of data in my CSV file (I got this file from odt, xls).
"FirstName","LastName","countMin", "countMax"
"FirstNameTest","LastNameTest",="01",="01"

So Library Office is nice to open this file, but csv-parser has respond me error.

Consider using "typedarray-to-buffer" module to improve browser behaviour

I was just doing some experiments with using this module in conjunction with @maxogden's websocket-stream module and hit a couple of roadblocks with regards to the way the buffers were handled. Here's an example of the client code I'm writing:

var websocket = require('websocket-stream');
var wss = websocket('ws://localhost:3000', { type: Uint8Array });
var csv = require('csv-parser');

wss.pipe(csv())
  .on('data', function(item) {
    console.log(item.Year);
  })
  .on('end', function() {
    console.log('done');
  });

It's more an experiment than anything else, and while csv-parser failed to work as expected in the first instance I found that using @feross's typedarray-to-buffer module to do a data = toBuffer(data) call early in the _transform method made everything play nicely...

Anyway, I've got the code in a branch here:

https://github.com/DamonOehlman/csv-parser/tree/browser-streaming-fix

LMK if you'd like a PR or if you want to take a different approach :)

Parser not working when there is a escaped quote

csv:

"col1","col2"
"aaa","test 32" 123"
"bbb","sss"

expected output:

{ col1: 'aaa', col2: 'test 32" 123' }
{ col1: 'bbb', col2: 'sss' }

current output:

{ col1: 'aaa', col2: 'test 32" 123"\n"bbb' }

code:

var csv = require('csv-parser');

fs.createReadStream('test3.csv')
        .pipe(csv())
        .on('data', function (data) {
            console.log('done', data);
        });

No error event?

I get a Error: Row length does not match headers if a row's length doesn't match its headers, which causes parsing of the whole file to fail. Is there not a way to log the invalid row with something like an error or invalid event, allowing the rest of the file's parsing to continue?

Enhancement: allow to plug in custom converters

For example, if I have a column called "Date" with values like:
4/23/12 18:25
I would like to provide a simple converter to have value in the json file look like this:
2012-04-23T18:25:43.511Z

Document the events emitted

Currently only the "data" event is documented. Please document all the events that are also emitted. Such as "end", "headers" etc.

maxed out JS memory - send large JSON to client

I am trying to send a large CSV file to the client using Hapi.js. I get this error when I try to hit the route:

FATAL ERROR: JS Allocation failed - process out of memory

server.route({
    method: 'GET',
    path: '/scheduleA',
    handler: function(req, res){
            var dfd = q.defer();
            var contributions = [];
            fs.createReadStream('./data/Form_460_-_Schedule_A_-_Monetary_Contributions.csv')
              .pipe(csv())
              .on('data', function(cont){
                contributions.push(cont)
              })
              .on('error', function(err){
                dfd.reject(err);
              })
              .on('end', function(){
                dfd.resolve(contributions);
              })

            dfd.promise.then(function(conts){
                res(conts)
            })
        }
    });

Can I send the full file to the client or does this error mean the json is too big?

CLI

bcsv is kinda confusing to explain, but i think csv-parser on the cli would make more sense. wanna write a simple cli API to convert csv to newline delimited json?

Keep headers order

csv-parser does not keep headers order.

for example:

sign;2015;2016
aaa;12;42

produces:

[
    {
        "2015": "12",
        "2016": "42",
        "sign": "aaa"
    }
]

Add newline option

Right now it only allows specifying a separator. Would be nice if it would support a custom newline option as well.

Column being padded to fixed length

I'm parsing a csv file that has an account number column with accounts from lengths ranging from 10 - 12 characters. It appears the parser is padding 0's in from of the records that have 10 or 11 characters. For example 55555555555 is being written as 005555555555. Is there any way to have this written as is? I'm writing the results to mongodb and my find queries aren't returning results due to the mismatch.

My work around currently is to check if the number starts with a 0 then remove it. This doesn't add too much overhead but I figured I could be missing something. Thanks!

devDependencies

I'm on a mobile, otherwise I'd do a PR, but please move the testing deps to devDependencies.

Not processes big files

I try to process big file (23K lines). Only around 13K lines are processed (i.e. "data" even is raised). And no error events are raised, no exceptions throw.
File is available by link (zipped): http://download.geonames.org/export/dump/cities15000.zip
My code:

function csvToMap(filename, columns, rowCallback) {
    return new Promise(function(resolve, reject) {
        try {
console.log(filename);
            var linesRead = 0;
            fs.createReadStream(filename)
                .pipe(csv({
                    separator: '\t',
                    headers: columns
                }))
                .on('data', function(data) {
                    try {
                        rowCallback(data);
                        linesRead++;
                    } catch (e) {
                        die(e, reject);
                    }
                })
                .on('end', () => {
                    console.log(filename + ": " + linesRead + " lines read");
                    resolve();
                })
                .on('error', (e) => {
                    die(e, reject);
                });

        } catch (e) {
            die(e, reject);
        }
    });
}

function die(msg, callback) {
    console.log("error: " + msg);
    if (callback) {
        callback(msg);
    }
    throw msg;
}

Does not work with Strings

Hey,

I ran into some issues with csv-join, because the CSV I was piping was a String Buffer. I am not sure weather you want to allow usage of Strings here, but if not, maybe there could be a hint about it in the docs.

Best,
Finn

How to close the stream?

Using the following code, will return the csv object and not the readStream object.
What is the best to close the stream at any time?

var rs = fs.createReadStream(fileToProcess)
                .pipe(csv())
                .on('headers', function (header)
                {
                    ....
                    rs.destory();
                })
....

An "headers" field value is overwritten by csv file headers property.

Assuming you have an "headers" csv field, the following code overwrites its values with the file's headers.

csv-parser/index.js

Lines 185 to 192 in d8791d3

if (Object.defineProperty) {
Object.defineProperty(this._Row.prototype, 'headers', {
enumerable: false,
value: this.headers
})
} else {
this._Row.prototype.headers = this.headers
}

I strongly suggest leaving the _Row.prototype safe from any additional property.

null fields

certain terrible programs indicate omited fields via shouting null at you instead of just having an empty field, e.g.

a b c d
foo "bar,baz" NULL thing
a,b,c,d
foo,"bar,baz",NULL,thing

instead of

a b c d
foo "bar,baz" thing
a,b,c,d
foo,"bar,baz",,thing

it does understand quoting as fields with a , in them are quoted leading me to suspect a field containing the text null in all caps would be rendered as "NULL"

Double quotes in double-quoted values not handled correctly

Double quotes inside double-quoted values cause the parser to stop parsing at the row containing the double quote. When I run this:

printf 'name,age\njoe,40\n"will"iam",30\n"sam",35\n"jan",25' | csv-parser
-------------------------------^ there's a double quote in here

I get this:

{"name":"joe","age":"40"}
{"name":"will\"iam","age":"30\n\"sam\""}

It escaped the double quote nicely, but the "age" field is wrong, and the third and fourth rows were never parsed at all.

Error: Cannot find module 'is-property'

when running csv-parser, it misses a module

module.js:338
    throw err;
          ^
Error: Cannot find module 'is-property'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/.../node_modules/csv-parser/node_modules/generate-object-property/index.js:1:80)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

Performance

I have an exported CSV file here with 2.5 bln rows in it, each row at the moment contains only one column of length about 10 symbols.

When I stream it through fs.createReadStream, the entire stream finishes processing in 2.4 seconds.

When I redirect the stream into your library, using .pipe(csv()), well, I hit Ctrl+Break after 10 mins of it still trying to finish. It is just that slow.

UPDATE: I am processing the stream in paused mode, and I noticed that once I'm getting readable event, the following read always returns just one row. This is what seems to create the major bottleneck.

Is it possible to make this library buffer more than one row at a time, so we can make multiple read-s on each readable to get many rows at once?

[help] Don't understand "origin" from example

var stream = csv(['index', 'message'])
// Source from somewere with format 12312,Hello World
origin.pipe(stream)
  .on('data', function(data) {
    console.log(data) // Should output { "index": 12312, "message": "Hello World" }
  })

I tried this but not output as example comment

var stream = csv(['index', 'message'])
// Source from somewere with format 12312,Hello World
var origin = fs.createReadStream('test_csv_parse.csv');
origin.pipe(stream)
  .on('data', function(data) {
   // Should output { "index": 12312, "message": "Hello World" } 
   // but I got [ '12312', 'hello world' ]
    console.log(data)   })

What I'm wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.