Created
May 21, 2014 15:44
-
-
Save bmiles/6bdd2bdafd1ca9f1f00a to your computer and use it in GitHub Desktop.
small JS that finds and replaces tabs with a comma and renames the file to csv from asc.
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
var fs = require('fs'); | |
var filePath = process.argv[2]; | |
console.log(filePath); | |
fs.readFile(filePath, function (err, data) { | |
if (err) { | |
return console.log(err); | |
} | |
var newFilePath = filePath.replace(/asc/g, 'csv'); | |
var result = data.toString().replace(/\t/g, ', '); | |
fs.writeFile(newFilePath, result, 'utf8', function(err) { | |
if (err) return console.log(err); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment