title: How to parse CSV in node with streams?
body: <p>I have the following Parser:</p>
  
  <pre>
  function Parser(options) {
    options = options || {};
  
    // options.objectMode = true;
    options.encoding = 'utf8';
  
    Transform.call(this, options);
  
    this._rawHeader = [];
    this.header = null;
  }
  
  util.inherits(Parser, Transform);
  
  Parser.prototype._transform = function(data, encoding, done) {
    this.push(this._parseRow(data));
    done();
  };
  
  // Parse a data row into an object
  Parser.prototype._parseRow = function(row) {
    var fields = row.split(";");
    var obj = { code: fields[0], name: fields[1].trim() };
    return obj.toString();
  };
  
  
  var parser = new Parser({});
  
  // Pipe the streams
  process.stdin
    .pipe(parser)
    .pipe(process.stdout);
  </pre>
  
  <p>But, I get:</p>
  
  <pre>
  ACARIT21012;CASSA RURA has no method 'split'
      at Parser._parseRow (/Users/pmu/projects/b/s/lib/parser.js:38:20)
      at Parser._transform (/Users/pmu/projects/b/s/lib/parser.js:32:18)
      at Parser.Transform._read (_stream_transform.js:179:10)
      at Parser.Transform._write (_stream_transform.js:167:12)
      at doWrite (_stream_writable.js:219:10)
      at writeOrBuffer (_stream_writable.js:209:5)
      at Parser.Writable.write (_stream_writable.js:180:11)
      at write (_stream_readable.js:573:24)
      at flow (_stream_readable.js:582:7)
      at Socket.pipeOnReadable (_stream_readable.js:614:5)
  </pre>
  
  <p>I suspect the stream is broken, but not sure how to prevent this from happening</p>