The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
How to return byte array output from the script into the pipeline
KanikaAg15
Member Posts: 19 Learner II
in Help
Hi,
I have implemented a script for decoding an xlsm file but somehow I am facing issue in using the decoded data into the next operator within a pipeline.
I have used macros to store output but it has capability of storing data in the string format.
It would be great if some alternative can be suggested.
I have implemented a script for decoding an xlsm file but somehow I am facing issue in using the decoded data into the next operator within a pipeline.
I have used macros to store output but it has capability of storing data in the string format.
It would be great if some alternative can be suggested.
0
Best Answer
-
MartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data ScientistHi,I think you want to use something like this:
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.commons.codec.binary.Base64;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorDescription;
import com.rapidminer.operator.nio.file.SimpleFileObject;
String originalString = "Just a text";
byte[] decodedBytes = Base64.decodeBase64(originalString);
File tempFile = null;
try {
tempFile = File.createTempFile("rm-", ".tempFile");
tempFile.deleteOnExit();
FileOutputStream fos = new FileOutputStream(tempFile);
fos.write(decodedBytes);
fos.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
SimpleFileObject fileObject = new SimpleFileObject(tempFile);
return fileObjectThis give you a purple fileObject which can be used with any other Read operator.Best,Martin
- Sr. Director Data Solutions, Altair RapidMiner -
Dortmund, Germany1
Answers
If this is a commercial request, please consult support.rapidminer.com so we can assign more resources.
Dortmund, Germany
thanks fore revert. we cannot raise any commerical request. My only limitation is the I have a data within byte array which I need as output from the execute script operator. If you can suggest a method around that would be a great help.
Dortmund, Germany
Dortmund, Germany
Please find the below script. The output that is getting stored in byte array i.e decodedByte. I need that as an output from execute operator and dont want to store the file in local repository.