Commit fd13a96c authored by gustawdaniel's avatar gustawdaniel
Browse files

Dropped junk lines

parent 845527b6
......@@ -36,6 +36,7 @@ const FILES_FILTER = (e: string, i: number) => i < Infinity
const ROWS_FILTER = (e: string, i: number) => i <= Infinity
const DROP_SPACES = (l: string): string => l.replace(/\s+/g, '')
const DROP_JUNK_LINES = (l: string): string => l.replace(/(Nr)|(data)|(WALUTA\/CURRENCY)|(\.tab)/ig, '')
const DROP_EMPTY_LINES = (e:string) => !/^,*$/.test(e)
const testYearData = (r:YearData):void => {
......@@ -66,11 +67,12 @@ const main = () => {
.toString()
.split(`\n`)
.map(DROP_SPACES)
.map(DROP_JUNK_LINES)
.filter(DROP_EMPTY_LINES)
.filter(ROWS_FILTER)
.map(l => l.split(','));
console.table(arr.map(l => l.filter((e,i) => i < 3 || Math.abs(i - 27) < 5)));
console.table(arr.map(l => l));
const head = arr.shift()
if (!head) throw Error('File do not have header line.')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment