source: Dev/trunk/src/node_modules/ya-csv/test/echo.js @ 489

Last change on this file since 489 was 489, checked in by hendrikvanantwerpen, 11 years ago

Update node modules

File size: 711 bytes
Line 
1var csv  = require('../lib/ya-csv'),
2    util = require('util');
3
4util.debug('start');
5
6if (process.argv.length < 3) {
7    util.error("Usage: node " + process.argv[1] + " <csv file>");
8    process.exit(1);
9}
10
11var file = process.argv[2];
12
13var csvIn = csv.createCsvFileReader(file, {
14    'separator': ',',
15    'quote':   '"',
16    'comment': '#',
17});
18var csvOut = new csv.CsvWriter(process.stdout, {
19    'encoding': 'utf8'       
20});
21
22var lines   = 0;
23var columns = 0;
24
25csvIn.addListener('end', function() {
26    util.debug('end');
27    util.debug(columns + ' columns, ' + lines + ' lines');
28});
29
30csvIn.addListener('data', function(data) {
31    lines++;
32    columns += data.length;
33    csvOut.writeRecord(data);
34});
Note: See TracBrowser for help on using the repository browser.