Skip to content

Instantly share code, notes, and snippets.

@garaemon
Created May 15, 2012 07:01
Show Gist options
  • Save garaemon/2699669 to your computer and use it in GitHub Desktop.
Save garaemon/2699669 to your computer and use it in GitHub Desktop.
converting csv to dot file
#!/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