MCPcopy Create free account
hub / github.com/Keyang/node-csvtojson / filterHeader

Method filterHeader

src/ProcessorLocal.ts:161–199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

159 return this.processCSVBody(lines);
160 }
161 private filterHeader() {
162 this.runtime.selectedColumns = [];
163 if (this.runtime.headers) {
164 const headers = this.runtime.headers;
165 for (let i = 0; i < headers.length; i++) {
166 if (this.params.ignoreColumns) {
167 if (this.params.ignoreColumns.test(headers[i])) {
168 if (this.params.includeColumns && this.params.includeColumns.test(headers[i])) {
169 this.runtime.selectedColumns.push(i);
170 } else {
171 continue;
172 }
173 } else {
174 this.runtime.selectedColumns.push(i);
175 }
176 } else if (this.params.includeColumns) {
177 if (this.params.includeColumns.test(headers[i])) {
178 this.runtime.selectedColumns.push(i);
179 }
180 } else {
181 this.runtime.selectedColumns.push(i);
182 }
183 // if (this.params.includeColumns && this.params.includeColumns.test(headers[i])){
184 // this.runtime.selectedColumns.push(i);
185 // }else{
186 // if (this.params.ignoreColumns && this.params.ignoreColumns.test(headers[i])){
187 // continue;
188 // }else{
189 // if (this.params.ignoreColumns && !this.params.includeColumns){
190 // this.runtime.selectedColumns.push(i);
191 // }
192
193 // }
194 // }
195 }
196 this.runtime.headers = filterArray(this.runtime.headers, this.runtime.selectedColumns);
197 }
198
199 }
200 private processCSVBody(lines: string[]): ProcessLineResult[] {
201 if (this.params.output === "line") {
202 return lines;

Callers 4

processDataWithHeadMethod · 0.95
browser.jsFile · 0.80
csvtojson.min.jsFile · 0.80
ProcessorLocal.jsFile · 0.80

Calls 1

filterArrayFunction · 0.90

Tested by

no test coverage detected