How to use tFileInputDelimited and Iterate

One Star

How to use tFileInputDelimited and Iterate

Hi,
i have a question to component tFileInputDelimited (and the other tFileInput components). There can be two row outputs: main and iterate. How to use main is clear. But how can i use iterate? How does it work? I didn't find any example for. Can anyone give me one please? Thank you. I use java projects.
Regards,
Falk
Community Manager

Re: How to use tFileInputDelimited and Iterate

Hello
The 'iterate' link fires the next subJob based on each row, for example
tFileInputDelimited--Iteate--tJava
if there are three rows come from input component(tFileInputDelimited), tJava component will work three times.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: How to use tFileInputDelimited and Iterate

Hi Shong,
i understand what you mean, but not realy how it works. I looked in the generated source code from TOS and didn't find how i can access the fields each row. I created a simple job. tFileDelimited input (with two culumns named "newColumn" and "newColumn1") and an iterate connection to tJava. I'am using TOS 3.2.1.
				while (fid_tFileInputDelimited_1.nextRecord()) {
/**
* stop
*/
/**
* start
*/
currentComponent = "tFileInputDelimited_1";
tos_count_tFileInputDelimited_1++;
/**
* stop
*/
NB_ITERATE_tJava_1++;
/**
* start
*/
ok_Hash.put("tJava_1", false);
start_Hash.put("tJava_1", System.currentTimeMillis());
currentComponent = "tJava_1";
int tos_count_tJava_1 = 0;
String foo = "bar";
/**
* stop
*/
/**
* start
*/
currentComponent = "tJava_1";
tos_count_tJava_1++;
/**
* stop
*/
/**
* start
*/
currentComponent = "tJava_1";
ok_Hash.put("tJava_1", true);
end_Hash.put("tJava_1", System.currentTimeMillis());
/**
* stop
*/
/**
* start
*/
currentComponent = "tFileInputDelimited_1";
}
Community Manager

Re: How to use tFileInputDelimited and Iterate

Hello
I looked in the generated source code from TOS and didn't find how i can access the fields each row

If you want to access the fields each row, you can use tFlowToIterate component, about its usage, see 5827.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: How to use tFileInputDelimited and Iterate

Hi Shong
thank you for your answer. For me it is not easy to understand why i must send a main stream to a tFlowToIterate, because tFileDelimited already use a iterate. Which information are sending to tJava in our example with iterate? Only the number of rows i see. Is it right?
Regards
Falk
One Star

Re: How to use tFileInputDelimited and Iterate

Well, I identify that when ITERATE is in use and to access a field, you can use 
fid_tFileInputDelimited_1.get(indx)

Where indx is the number of column that you want to access.
I prefer always access direct to the object in the iterate instead of use an tFlowToIterate, because these component sometimes present strange behaviour and for the cost (in memory) of use a proxy (like a tFlowToIterate).