@@ -15,16 +15,16 @@ let rowCount = 0;
15
15
exports . init = function init ( cfg ) {
16
16
return co ( function * gen ( ) {
17
17
18
- const delimiter = cfg . reader . delimiter || ',' ;
18
+ const delimiter = cfg . writer . delimiter || ',' ;
19
19
console . log ( 'Using delimiter: \'%s\'' , delimiter ) ;
20
20
const options = {
21
21
header : true ,
22
22
delimiter
23
23
} ;
24
24
25
- if ( cfg . reader . columns ) {
25
+ if ( cfg . writer . columns ) {
26
26
27
- const columns = Object . keys ( _ . keyBy ( cfg . reader . columns , 'property' ) ) ;
27
+ const columns = Object . keys ( _ . keyBy ( cfg . writer . columns , 'property' ) ) ;
28
28
29
29
console . log ( 'Configured column names:' , columns ) ;
30
30
options . columns = columns ;
@@ -44,11 +44,6 @@ exports.init = function init(cfg) {
44
44
exports . process = function ProcessAction ( msg , cfg ) {
45
45
// eslint-disable-next-line consistent-this
46
46
const self = this ;
47
- const startRow = cfg . reader . startRow || 0 ;
48
-
49
- if ( startRow !== 0 && rowCount === 0 ) {
50
- console . log ( 'Skipping the first %s rows' , startRow + 1 ) ;
51
- }
52
47
53
48
if ( timeout ) {
54
49
clearTimeout ( timeout ) ;
@@ -57,7 +52,7 @@ exports.process = function ProcessAction(msg, cfg) {
57
52
timeout = setTimeout ( ( ) => {
58
53
console . log ( 'Closing the stream due to inactivity' ) ;
59
54
co ( function * gen ( ) {
60
- const finalRowCount = rowCount - startRow ;
55
+ const finalRowCount = rowCount ;
61
56
console . log ( 'The resulting CSV file contains %s rows' , finalRowCount ) ;
62
57
stringifier . end ( ) ;
63
58
@@ -79,48 +74,12 @@ exports.process = function ProcessAction(msg, cfg) {
79
74
} ) ;
80
75
} , 10000 ) ;
81
76
82
- if ( startRow <= rowCount ) {
83
- let row = msg . body ;
84
- if ( cfg . reader . columns ) {
85
- const columns = Object . keys ( _ . keyBy ( cfg . reader . columns , 'property' ) ) ;
86
- row = _ . pick ( msg . body , columns ) ;
87
- }
88
- stringifier . write ( row ) ;
77
+ let row = msg . body ;
78
+ if ( cfg . writer . columns ) {
79
+ const columns = Object . keys ( _ . keyBy ( cfg . writer . columns , 'property' ) ) ;
80
+ row = _ . pick ( msg . body , columns ) ;
89
81
}
82
+ stringifier . write ( row ) ;
90
83
rowCount ++ ;
91
84
this . emit ( 'end' ) ;
92
85
} ;
93
-
94
- /**
95
-
96
-
97
- co(function* proc() {
98
- yield init();
99
-
100
- for (let i = 0; i <= 100; i++) {
101
-
102
- processAction({
103
- body: {
104
- run: i,
105
- timestamp: Date.now()
106
- }
107
- });
108
- }
109
-
110
- setTimeout(()=> {
111
-
112
- console.log('Next round');
113
-
114
-
115
- for (let i = 100; i <= 200; i++) {
116
-
117
- processAction({
118
- body: {
119
- run: i,
120
- timestamp: Date.now()
121
- }
122
- });
123
- }
124
- }, 10000);
125
- });
126
- **/
0 commit comments