"Get output ExampleSet error!"

hotae
hotae New Altair Community Member
edited November 5 in Community Q&A
Hi,
I want to import a csv file as a ExampleSet using CSVExampleSource, so I code sa:
RapidMiner.init();
Operator trainingDataReader = OperatorService.createOperator(CSVExampleSource.class);
            trainingDataReader.setParameter(CSVExampleSource.PARAMETER_CSV_FILE, "C:/Documents and Settings/tmd/data/data_forPrediction.csv");
            trainingDataReader.setParameter(CSVExampleSource.PARAMETER_COLUMN_SEPARATORS, "\t");
            trainingDataReader.setParameter(CSVExampleSource.PARAMETER_TRIM_LINES, "true");
            trainingDataReader.setParameter(CSVExampleSource.PARAMETER_FIRST_ROW_AS_NAMES, "true");
            Process process = new Process();
            //add operators to process
            process.getRootOperator().getSubprocess(0).addOperator(trainingDataReader);
            IOContainer ioResult = process.run();
            ExampleSet exampleSet = (ExampleSet) ioResult.getElementAt(0);
But I got the following error:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at com.rapidminer.operator.IOContainer.getElementAt(IOContainer.java:112)
It seems nothing output by process.run();
Any one tell me how to do?
Thanks!

Answers

  • aborg
    aborg New Altair Community Member
    It seems you forget to connect the output to the Process' port. I guess after fixing that you will be ok.
  • hotae
    hotae New Altair Community Member
    aborg wrote:

    It seems you forget to connect the output to the Process' port. I guess after fixing that you will be ok.
    Could you give me a hint to set it? I don't know how to connect the output to the process's port

    Thank you!
  • aborg
    aborg New Altair Community Member
    Sorry, I have no out ot the box working example. Something along the following lines might help (not tested):

    final ProcessRootOperator rootOp = process.getRootOperator();
    final ExecutionUnit executionUnit = rootOp.getSubprocess(0);
    int i = 0;
    for (final OutputPort outPort : newOp.getOutputPorts().getAllPorts()) {
      final InputPort inputPort = executionUnit.getInnerSinks().getPortByIndex(i++);
      outPort.connectTo(inputPort);
    }
  • hotae
    hotae New Altair Community Member
    It's works! Thanks!