Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test tab delimiter

  • Loading branch information...
commit 35956a457e623f9f1e25484f79514728fdf8b403 1 parent b3a87b7
@wdavidw authored
View
29 test/delimiter.js
@@ -30,5 +30,34 @@ module.exports = {
);
fs.unlink(__dirname+'/delimiter/empty_value.tmp');
});
+ },
+ 'Test tabs to comma': function(){
+ csv()
+ .fromPath(__dirname+'/delimiter/tab_to_coma.in',{
+ delimiter: '\t'
+ })
+ .toPath(__dirname+'/delimiter/tab_to_coma.tmp',{
+ delimiter: ','
+ })
+ .transform(function(data,index){
+ assert.strictEqual(5,data.length);
+ if(index===0){
+ assert.strictEqual('',data[1]);
+ assert.strictEqual('',data[4]);
+ }else if(index===1){
+ assert.strictEqual('',data[0]);
+ assert.strictEqual('',data[3]);
+ assert.strictEqual('',data[4]);
+ }
+ return data;
+ })
+ .on('end',function(count){
+ assert.strictEqual(2,count);
+ assert.equal(
+ fs.readFileSync(__dirname+'/delimiter/tab_to_coma.out').toString(),
+ fs.readFileSync(__dirname+'/delimiter/tab_to_coma.tmp').toString()
+ );
+ fs.unlink(__dirname+'/delimiter/tab_to_coma.tmp');
+ });
}
}
View
2  test/delimiter/tab_to_coma.in
@@ -0,0 +1,2 @@
+20322051544 8.8017226E7 45
+ 1974 8.8392926E7
View
2  test/delimiter/tab_to_coma.out
@@ -0,0 +1,2 @@
+20322051544,,8.8017226E7,45,
+,1974,8.8392926E7,,
Please sign in to comment.
Something went wrong with that request. Please try again.