Created
October 5, 2017 15:11
-
-
Save stepankuzmin/c8c718c674ce79f3578bd4fb392be616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const iconv = require('iconv-lite'); | |
| const buffer = fs.readFileSync(process.argv[2]); | |
| const csv = iconv.decode(buffer, 'win1251'); | |
| const rows = csv.toString().split('\n'); | |
| const regexp = new RegExp('Заработная плата|Аванс', 'ig'); | |
| const result = rows.slice(1).reduce((acc, row) => { | |
| const values = row.split(';'); | |
| if (regexp.test(values[5])) { | |
| acc.push({ | |
| date: values[3], | |
| summ: values[6] | |
| }); | |
| } | |
| return acc; | |
| }, []); | |
| console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment