I think using tJavaFlex, tMap and tFlowToIterate components you can easily split the data. You can start off by arranging the components as shown below:
![image](https://lh4.googleusercontent.com/EVaQdxCPhhZhRAqRuDplgpOv5q5F79zARifktknsBO1qisD7l-WpwlwUegnBtYjgallRSOopbtqxKVwBt50wR3O23OdiodmI4fI6zscqeg9b441wH5UD4CRmt1vwgbonvgxd-m3B)
Open the Map Editor and map the data as shown:
![image](https://lh3.googleusercontent.com/RY4WVOoOPfjSB8RKVV6TNSyqi3kPchCz4ioUx08t8170s9UqV3p4Sc7C0TKBs5B_6aE6D-uqyZj02Aog3EM8Kxl_uSeJqhnpWfksKM6lHrthbScLcYBQJwm1ANz0GbclejX9MZCK)
In the Map Editor output table add a new row called “iterations” of “long” type to hold the difference between the dates.
tFlowToIterate components need no configurations to be done. It will by default pass on the values to the tJavaFlex.
Add the below code to the tJavaFlex component:
Start Code:
// start part of your Java code
int currentId = (Integer)globalMap.get("res.id");
String currentName = (String)globalMap.get("res.name");
Long iterations = (Long)globalMap.get("res.iterations");
Date dateFrom = (java.util.Date)globalMap.get("res.dateFrom");
Date dateTo = (java.util.Date)globalMap.get("res.dateTo");
for(int i=0; i<((Long)globalMap.get("res.iterations")); i++) {
Main Code:
row2.new_id = i+1;
row2.id = currentId;
row2.name = currentName;
row2.dateFrom = TalendDate.addDate(dateFrom, i, "dd");
row2.dateTo = TalendDate.addDate(dateFrom, i+1, "dd");
End Code:
}
Like the tFlowToIterate component tLogRow also do not need any configurations to be done. You can just go ahead and execute the job which will give you the below output.
Hope this was what you were looking for.
Get your Talend certification today to become certified professional.
Thanks.