Last active
September 29, 2016 09:27
-
-
Save JacobBovee/3035644040c70b1611b55400e94a69c1 to your computer and use it in GitHub Desktop.
This file contains 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
'use strict' | |
const fs = require('fs') | |
const rs = fs.createReadStream(process.argv[2]) | |
const ws = fs.createWriteStream(process.argv[3]) | |
function run() { | |
fs.statSync(process.argv[3], function(err) { | |
if (err) return | |
fs.unlinkSync(process.argv[3]) | |
}) | |
rs.on('data', function(buffer) { | |
const chunk = buffer.toString().split('\n') | |
chunk.map(function(val, i) { | |
const row = val.split(',') | |
if (+row[1] >= +process.argv[4]) { | |
const newRow = `${row[0]},${row.slice(3)}\n` | |
ws.write(newRow) | |
} | |
}) | |
}) | |
rs.on('end', function() { | |
ws.end() | |
}) | |
} | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment