Created
May 15, 2012 07:01
-
-
Save garaemon/2699669 to your computer and use it in GitHub Desktop.
converting csv to dot file
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
#!/usr/bin/env node | |
// csv_to_dot.js | |
var argv = require("optimist").argv; | |
var fs = require("fs"); | |
var from_file = argv["_"][0]; | |
console.log("digraph G {\n"); | |
fs.readFileSync(from_file, "utf8") | |
.toString() | |
.split("\n") | |
.forEach(function(line) { | |
var elements = line.split(","); | |
console.log("\"" + elements[0] + "\" -> \"" + elements[2] + "\" [label=\"" | |
+ elements[1] + "\"];\n"); | |
}); | |
console.log("\n}\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment