Skip to content

Commit af7eda5

Browse files
committed
fix #120
1 parent e6919b7 commit af7eda5

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ build
1414
graph.png
1515
.project
1616
.settings
17+
.vscode

libs/core/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ function isQuoteClose(str,param){
4242
return count%2!==0;
4343
}
4444
function rowSplit(rowStr, param) {
45+
if (rowStr ===""){
46+
return [];
47+
}
4548
var quote=param.quote;
4649
var trim=param.trim;
4750
if (param.needCheckDelimiter===true){

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"email": "t3dodson@gmail.com"
1919
}
2020
],
21-
"version": "1.0.0",
21+
"version": "1.0.1",
2222
"keywords": [
2323
"csv",
2424
"csvtojson",

test/testCSVConverter2.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,24 @@ describe("CSV Converter", function() {
223223
})
224224
rs.pipe(conv);
225225
})
226+
it ("should get delimiter automatically if there is no header",function(done){
227+
var test_converter = new Converter({
228+
delimiter: 'auto',
229+
headers: ['col1', 'col2'],
230+
noheader: true,
231+
checkColumn: true
232+
});
233+
234+
var my_data = 'first_val\tsecond_val';
235+
test_converter.fromString(my_data, function(err, result) {
236+
assert(!err);
237+
assert.equal(result.length,1);
238+
assert.equal(result[0].col1,"first_val");
239+
assert.equal(result[0].col2,"second_val");
240+
done();
241+
});
242+
});
243+
226244
// it ("should convert big csv",function(done){
227245
// // var rs=fs.createReadStream(__dirname+"/data/large-csv-sample.csv");
228246
// var rs=fs.createReadStream("/Users/kxiang/tmp/csvdata");

0 commit comments

Comments
 (0)