Skip to content

Instantly share code, notes, and snippets.

@botic
Created July 15, 2012 07:13
Show Gist options
  • Select an option

  • Save botic/3115660 to your computer and use it in GitHub Desktop.

Select an option

Save botic/3115660 to your computer and use it in GitHub Desktop.
Scripts to convert Taverna output files into a single CSV
/*
* This script reads all files inside a given directory. The filenames are in the following format:
* 1 ... n --> sub workflow n returned a value
* n.error --> sub workflow n threw an error and was not successful
*
*/
var io = require("io");
var fs = require("fs");
var term = require("ringo/term");
var sytem = require("system");
if (system.args.length !== 2) {
term.writeln(term.RED, "Missing parameter: path to directory with input file.");
}
var count = 0;
do {
// Read the next file from the automated workflow
var fileName = system.args[1] + "/" + (++count);
if (fs.exists(fileName)) {
var stream = fs.open(fileName, "r");
term.writeln(count + "," + stream.read());
} else if (fs.exists(fileName + ".error")) {
term.writeln(count + ",-1");
} else {
// Abort. Last file read
count = -1;
}
} while (count > 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment