public String transform() { StringWriter tabularASCII = new StringWriter(); stringData = stringData.replace("\"", ""); String[] rows = stringData.split("/n"); for (String row : rows) { String[] elements = row.split(","); String cleanedRow = ""; for (String element : elements) { element = element.trim(); cleanedRow += element + " "; } cleanedRow = cleanedRow.substring(0, cleanedRow.lastIndexOf(" ") - 1); tabularASCII.append(cleanedRow + "\n"); } FileUtils.writeTextFile(tabularASCII.toString(), FileUtils.getWorkspace(), outputFileName); return outputURL; }
public class Psxyz extends ToolkitOperator { /* ASUMPTION: the input dataset is in tabular space delimited ASCII file */ private static final String PLOTTER_2D = FileUtils.getGMTScripts() + "wrapper-psxyz.sh"; public Psxyz(String asciiDataURL) { super(asciiDataURL, "xyzData.txt", true, false, "3Dbarchart.ps"); } public String transform( String B, String J, String JZ, String R, String E, String S, String W, String G) { String command = PLOTTER_2D + " " + inputPath + " " + outputPath + " " + B + " " + J + " " + JZ + " " + R + " " + E + " " + S + " " + W + " " + G; CommandRunner.run(command); return outputURL; } }