Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Created October 5, 2017 15:11
Show Gist options
  • Save stepankuzmin/c8c718c674ce79f3578bd4fb392be616 to your computer and use it in GitHub Desktop.
Save stepankuzmin/c8c718c674ce79f3578bd4fb392be616 to your computer and use it in GitHub Desktop.
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