Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'm from Germany and a real newbie on Talend.
For my bachelor thesis I am supposed to test the tool Talend Open Studio for Big Data. Part of my data is stored in a MongoDB. I want to split the string of the attribute machineTime into one column with Date and one with Time. For example, a string looks like this: machineTime: "14.05.2018 : 12:35". How can I implement this?
Thanx for your help.
Lara
So you have to write a code like this in tJavaFlex ( main code )
index = machineTime.indexOf(":");
machineDate = machineTime.substring(0,index);
machineNewTime = machineTime .substring(index+1,machineTime.length());
Now you can create two columns in tJavaFlex schema like machineDate and machineNewTime or whatever you like
and then whatever the output link name is the code will be like this
row2.machineDate = machineTime.substring(0,index);
row2.machineNewTime = machineTime .substring(index+1,machineTime.length());
Let me know in case you need more help
So you have to write a code like this in tJavaFlex ( main code )
index = machineTime.indexOf(":");
machineDate = machineTime.substring(0,index);
machineNewTime = machineTime .substring(index+1,machineTime.length());
Now you can create two columns in tJavaFlex schema like machineDate and machineNewTime or whatever you like
and then whatever the output link name is the code will be like this
row2.machineDate = machineTime.substring(0,index);
row2.machineNewTime = machineTime .substring(index+1,machineTime.length());
Let me know in case you need more help
Hello Prakhar,
Thank you very much for your help. I have now tried the code and every time I get the message that the series machineTime can not be resolved. Any suggestions on this?
Please upload some screenshots to show us where you write the code and which components the job contains.
This is where I wrote the code. I've also tried to write it at the end but it doesn't work.
See below screenshots, here are the Java codes on tJavaFlex.
index = row1.machineTime.indexOf(":");
row2.machineDate = row1.machineTime.substring(0,index);
row2.machineNewTime = row1.machineTime .substring(index+1,row1.machineTime.length());
Hello again,
I tried it the way you said.
With your setup, it worked. Then I tried it with my data from MongoDB (screenshots follow). First I only read the variable machineTime from MongoDB. Now I always get the following error message after running the job:Here is the complete structure of my job:
What is the error message? You forgot to upload the screenshots.
Thank you, I had not even noticed.
Here we go.