RapidMiner

‎12-16-2016 08:56 AM

Question

How can I upload a file (e.g. an Excel file) from my computer and process the results directly in RapidMiner Server?

Answer

Here is what you need:

 

  • RapidMiner Server up and running
  • The Text processing extension (on Server and on Studio)
  • Being able to create a Webservice from a RapidMiner process. See article How to create a webservice for details.

 

The solution in short:

 

  1. Create an HTML form which includes an input tag with type="file" and display it as a Web App visualization component
  2. Send the file via HTTP-Post to a RapidMiner process which has been published as a web service
  3. Store / Process the file and provide a success message

 

The solution in detail:

 

 

Spoiler

Hint

Using the special user "anonymous" makes the functionality much more convenient. This way the user who uploads the file does not need to reauthenticate himself for the upload. Therefore "anonymous" needs to have at least permission to execute within the folder in which the described processes are stored. See article Create and Manage "Special Users"  for further information.
In this case you need to grant the user anonymous the execute permissions for the folder where the processes are stored. If you want to store data, the user also needs the permission to write.
In addition you need to adapt the action URL. You need to include the keyword "public" between "rest" and "process" (http://localhost/api/rest/public/process/<web service name>)

 

  1. Create a folder in which you want to store the processes (and uploaded data if you wish) on the server.
  2. Now create the process which receives the uploaded file and processes it. The attached example process "Read file from web app - webservice" receives either one or two excel file(s) and stores them in the repository. Then it sends a success message.
  3. This process needs to be exported as webservice as described in the article How to create a webservice. Make sure that you have set the Output format to "HTML" and the MIME Type to "text/html".
  4. Create the process displaying the HTML form and set the Webservice URL as the value for the form "action" (see attached example process).
  5. Create the Upload component as "New visualization" component in your RapidMiner Server Web App.
  6. Make sure that you have set the Output format to "HTML" and the MIME Type to "text/html".

 

 

What are constraints of this feature?

  • If you enable the upload of multiple files at once (by using the keyword "multiple" in the HTML tag for the the input type="file") and you want to store them as one exampleset you have to ensure that the structure of the uploaded files is the same.
  • You can only upload as many files at once as you have input ports connected.
  • The operator "Publish to App" does not work in webservices since it is executed in a different session.

 

 Edit (2016/12/15):

I just uploaded new process versions which already store each uploaded file with the original name as well as the full file.

The webservice now also makes use of the Handle Exception Operator which helps you to deal with problems.

Edit (2016/12/16):

I just uploaded a new process version for the HTML form. It includes a version of the HTML form with which you can rename the file(s) you upload. Only works for single file uploads.

 

Output of example process "Read file from web app - HTML form"

 

Upload Component.PNG

 If you have selected a file for upload - the name is displayed

 

Upload Component - file selected.PNG

 

 Success message (output of the example process "Read file from web app - webservice")

 

Upload Component - success.PNG

Comments
Community Manager Community Manager
Community Manager

This is GREAT.  Thank you so much for posting this.  I have just installed it and it works very well.  One small question - how can I pass the Excel file name into the process so that it stores the data set using this name, rather than the "Uploaded file".  Or, even better, can there be a small dialog box that asks for the name for the new data set? before Start Upload?

RM Staff
RM Staff

Glad I could help. Smiley Happy

 

I just uploaded new versions of the processes which store the original files as repository examplesets and the full (i.e. appended) file.  Smiley Happy

 

Including a dialog box should be possible in the HTML form. I will check and let you know, how this can be achieved.

 

Best,

Edin