Skip to content

Commit

Permalink
Rename sample dir to samples; Fix readme sample syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Sep 26, 2010
1 parent 56b1248 commit e9767af
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 7 deletions.
15 changes: 12 additions & 3 deletions readme.md
Expand Up @@ -27,7 +27,11 @@ Using the library is a 4 steps process:
3. Transform the data (optional)
4. Listen to events (optional)

Here is a exemple:

// node samples/sample.js
var csv = require('csv');

csv()
.fromPath(__dirname+'/sample.in')
.toPath(__dirname+'/sample.out')
Expand All @@ -39,11 +43,16 @@ Using the library is a 4 steps process:
console.log('#'+index+' '+JSON.stringify(data));
})
.on('end',function(count){
console.log('Number of lines '+count);
console.log('Number of lines: '+count);
})
.on('error',function(error){
console.log(error.message);
});

// Print sth like:
// #0 ["2000-01-01","20322051544","1979.0","8.8017226E7","ABC","45"]
// #1 ["2050-11-27","28392898392","1974.0","8.8392926E7","DEF","23"]
// Number of lines: 2

Installing
----------
Expand Down Expand Up @@ -134,7 +143,7 @@ When the returned value is an array, the fields are merge in order. When the ret

Exemple of transform returning a string

// node sample/transform.js
// node samples/transform.js
var csv = require('csv');

csv()
Expand Down Expand Up @@ -173,7 +182,7 @@ You can define a different order and even different columns in the read options

When working with fields, the `transform` method and the `data` events recieve their `data` parameter as an object instead of an array where the keys are the field names.

// node sample/column.js
// node samples/column.js
var csv = require('csv');

csv()
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion sample/columns.js → samples/columns.js
@@ -1,7 +1,7 @@

// CSV sample - Copyright David Worms <open@adaltas.com> (MIT Licensed)

// node sample/column.js
// node samples/column.js
var csv = require('csv');

csv()
Expand Down
File renamed without changes.
9 changes: 7 additions & 2 deletions sample/sample.js → samples/sample.js
@@ -1,7 +1,7 @@

// CSV sample - Copyright David Worms <open@adaltas.com> (MIT Licensed)

// node sample/sample.js
// node samples/sample.js
var csv = require('csv');

csv()
Expand All @@ -15,8 +15,13 @@
console.log('#'+index+' '+JSON.stringify(data));
})
.on('end',function(count){
console.log('Number of lines '+count);
console.log('Number of lines: '+count);
})
.on('error',function(error){
console.log(error.message);
});

// Print sth like:
// #0 ["2000-01-01","20322051544","1979.0","8.8017226E7","ABC","45"]
// #1 ["2050-11-27","28392898392","1974.0","8.8392926E7","DEF","23"]
// Number of lines: 2
2 changes: 2 additions & 0 deletions samples/sample.out
@@ -0,0 +1,2 @@
2000-01-01,20322051544,1979.0,8.8017226E7,ABC,45
2050-11-27,28392898392,1974.0,8.8392926E7,DEF,23
File renamed without changes.
2 changes: 1 addition & 1 deletion sample/transform.js → samples/transform.js
@@ -1,7 +1,7 @@

// CSV sample - Copyright David Worms <open@adaltas.com> (MIT Licensed)

// node sample/transform.js
// node samples/transform.js
var csv = require('csv');

csv()
Expand Down

0 comments on commit e9767af

Please sign in to comment.