Permalink
Browse files

Fixed 'strDelimiter' option not being used in .each and .parse function

  • Loading branch information...
1 parent ac2e136 commit 925dcc2040b808c7e9e6a59e286d670e35e1161b @robofish committed Oct 25, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/csv.js
View
@@ -116,7 +116,7 @@ exports.each = function (filename, options) {
var stream = new events.EventEmitter();
var emit_row = function(row) {
- var data = CSVToArray(row)[0];
+ var data = CSVToArray(row, strDelimiter)[0];
if (options["headers"]) {
if (headers == null) {
headers = data;
@@ -181,13 +181,14 @@ exports.parse = function(str, options, data_listener) {
throw new Exception("Data listener must be provided");
}
options = (options || {});
+ var strDelimiter = (options.strDelimiter || ",");
var stream = new events.EventEmitter();
stream.addListener("data", data_listener);
var parts = str.split("\n");
var pl = parts.length;
var headers = null;
for( var i = 0; i < pl; i++) {
- var data = CSVToArray(parts[i])[0];
+ var data = CSVToArray(parts[i], strDelimiter)[0];
if (options["headers"]) {
if (headers == null) {
headers = data;

0 comments on commit 925dcc2

Please sign in to comment.