title: Read csv files in stream and store them in database
body: <p>I have a few huge csv files, what I need to store in a mongo database. Because these files are too big, I need to use stream. I pause the stream while the data writing into the database.</p>
  
  <pre><code>var fs = require('fs');
  var csv = require('csv');
  var mongo = require('mongodb');
  
  var db = mongo.MongoClient.connect...
  
  var readStream = fs.createReadStream('hugefile.csv');
  readStream.on('data', function(data) {
    readStream.pause();
    csv.parse(data.toString(), { delimiter: ','}, function(err, output) {
      db.collection(coll).insert(data, function(err) {
        readStream.resume();
      });
    });
  });
  readStream.on('end', function() {
    logger.info('file stored');
  });
  </code></pre>
  
  <p>But the <code>csv.parse</code> drop an error, because I would need to read the files line by line to handle them as csv, and convert to json for the mongodb. Maybe I should not pause them, but use an interface. I didn't find any solution for this yet.</p>
  
  <p>Any help would be appreciated!</p>