Skip to content

Instantly share code, notes, and snippets.

@johndstein
Created October 17, 2017 13:15
Show Gist options
  • Save johndstein/f02cb8720ed2c57fc500f9905bb48f35 to your computer and use it in GitHub Desktop.
Save johndstein/f02cb8720ed2c57fc500f9905bb48f35 to your computer and use it in GitHub Desktop.
Add fixed value column to CSV file
#!/usr/bin/env node
'use strict';
const path = require('path');
if (process.argv.length < 4) {
console.error(`
Usage: ${path.basename(process.argv[1])} HEADER VALUE
We read from STDIN and write to STDOUT.
`);
process.exit(1);
}
require('csv-stream-transform')({
transform(row, cb) {
row[process.argv[2]] = process.argv[3];
cb(null, row);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment