try {
Instances i;
// read from stdin and print statistics
if (args.length == 0) {
DataSource source = new DataSource(System.in);
i = source.getDataSet();
System.out.println(i.toSummaryString());
} // read file and print statistics
else if ((args.length == 1) && (!args[0].equals("-h"))
&& (!args[0].equals("help"))) {
DataSource source = new DataSource(args[0]);
i = source.getDataSet();
System.out.println(i.toSummaryString());
} // read two files, merge them and print result to stdout
else if ((args.length == 3)
&& (args[0].toLowerCase().equals("merge"))) {
DataSource source1 = new DataSource(args[1]);
DataSource source2 = new DataSource(args[2]);
i = Instances.mergeInstances(source1.getDataSet(),
source2.getDataSet());
System.out.println(i);
} // read two files, append them and print result to stdout
else if ((args.length == 3)
&& (args[0].toLowerCase().equals("append"))) {
DataSource source1 = new DataSource(args[1]);
DataSource source2 = new DataSource(args[2]);
if (!source1.getStructure().equalHeaders(source2.getStructure())) {
throw new Exception(
"The two datasets have different headers!");
}
Instances structure = source1.getStructure();
System.out.println(source1.getStructure());
while (source1.hasMoreElements(structure)) {
System.out.println(source1.nextElement(structure));
}
structure = source2.getStructure();
while (source2.hasMoreElements(structure)) {
System.out.println(source2.nextElement(structure));
}
} // read file and seed value, randomize data and print result to stdout
else if ((args.length == 3)
&& (args[0].toLowerCase().equals("randomize"))) {
DataSource source = new DataSource(args[2]);
i = source.getDataSet();
i.randomize(new Random(Integer.parseInt(args[1])));
System.out.println(i);
} // wrong parameters
else {
System.err.println(