Created
July 15, 2012 07:13
-
-
Save botic/3115660 to your computer and use it in GitHub Desktop.
Scripts to convert Taverna output files into a single CSV
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
| /* | |
| * 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