Skip to content

Instantly share code, notes, and snippets.

@kellan
Created October 19, 2018 16:39
Show Gist options
  • Save kellan/8b2b9f8bc8b547ba5f269695fb1374b6 to your computer and use it in GitHub Desktop.
Save kellan/8b2b9f8bc8b547ba5f269695fb1374b6 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const es = require('event-stream');
const stripBom = require('strip-bom');
let filepath = './short.tsv';
let reader = fs.createReadStream(filepath);
let keys;
reader.pipe(es.split())
.pipe(es.filterSync((line) => {return line}))
.pipe(es.mapSync(line => { return stripBom(line)}))
.pipe(es.mapSync(line => {
row = line.split("\t");
if (!keys) {
keys = row; // grab the first line as keys
} else {
storerow(keys, row);
}
}));
function storerow(keys, row) {
//console.log(keys, row);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment