I see two ways to do this.
The first would be to programmatically change the XML definition of your process. Rapidminer processes are defined by an XML file with the extension .rmp . In the file you will find the definition of the operator that you want to change. This is an excerpt from a simple process that defines the Read Excel statement:
<operator activated="true" class="read_excel" compatibility="5.3.005" expanded="true" height="60" name="Read Excel" width="90" x="313" y="75"> <parameter key="excel_file" value="D:\file.xls"/> <parameter key="sheet_number" value="1"/> <parameter key="imported_cell_range" value="A1"/> <parameter key="encoding" value="SYSTEM"/> <parameter key="first_row_as_names" value="true"/> <list key="annotations"/> <parameter key="date_format" value=""/> <parameter key="time_zone" value="SYSTEM"/> <parameter key="locale" value="English (United States)"/> <list key="data_set_meta_data_information"/> <parameter key="read_not_matching_values_as_missings" value="true"/> <parameter key="datamanagement" value="double_array"/> </operator>
I highlighted the part in which the path to the excel file. You can overwrite this in your application. Just be careful not to break the XML file.
Another way is to change the statement after loading the process into your Java application. You can get a link to your operator on Process#getOperator(String name) or Process#getAllOperators() . I assume this should be one of these classes:
com.rapidminer.operator.io.ExcelExampleSource com.rapidminer.operator.nio.ExcelExampleSource
When you find the correct operator, you change the path to Operator#setParameter(String key, String Value) .
This code works for me with RapidMiner 5.3: (the process is just an Excel read statement and a CSV burn statement)
package sorapid; import com.rapidminer.Process; import com.rapidminer.RapidMiner; import com.rapidminer.operator.Operator; import com.rapidminer.operator.OperatorException; import com.rapidminer.operator.io.ExcelExampleSource; import com.rapidminer.tools.XMLException; import java.io.File; import java.io.IOException; public class SOrapid { public static void main(String[] args) { try { RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE); RapidMiner.init(); Process process = new Process(new File("c:\\Users\\Matlab\\.RapidMiner5\\repositories\\Local Repository\\processes\\test.rmp")); Operator op = process.getOperator("Read Excel"); op.setParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE, "d:\\excel.xls"); process.run(); } catch (IOException | XMLException | OperatorException ex) { ex.printStackTrace(); } } }
source share