One Star

file count

Hi friends..
Need your help.
I use tfilelist--iterate1--tfileinpute
:
:
iterate2
:
tjava
in tjava i want the total number of files in the path..
my codeSmiley Frustratedystem.out.println("count " + ((Integer)globalMap.get("tFileList_1_NB_FILE"));
i have three files.
I need the printed message count : 3
instead i get count :1
count : 2
count :3
If i could get the total number of files in the first iteration it wud be helpful to solve my issue.
Note: do v have any component to fetch all files and print count?
Thanks in advance
8 REPLIES

Re: file count

Hi
Set up the job like this:
tFileList --iterate1--tfileinput
|
on subjob ok
|
tjava
with the same code and everything you have.
Regards,
Brandon
One Star

Re: file count

hi brandon,
Thanks for the reply,
I can get the count as 3 if i have tjava in tfilelist but every time it iterate i want it to display a print message and that message should be printed only when the count of files is more than one.
For instance,
I use tfilelist--iterate1--tfileinput
:
:
iterate2
:
tjava
in tjava,
System.out.println("Total row count : " + globalMap.get("tJavaRow_1_NB_LINE"));
Here,in case of multiple files,it prints different different row count each time.
i want to set condition before tjava accordingly so that it prints this message only when there is more than only one file..
How do i do that?.
Thnak you

Re: file count

Hi elma_ann
I do not understand clearly where is the tjavaRow which is being used in this condition ( globalMap.get("tJavaRow_1_NB_LINE")) )?
Maybe you could include some screenshots to give me a better understanding.
to add a condition to tJava try the following:

tfilelist--iterate1--tfileinput
:
:
if
:
tjava

in the if add the following code:
((Integer)globalMap.get("tFileList_1_NB_FILE"))>1
One Star

Re: file count

Hi Brandon!!!
screenshots attached.
the if condition becomes true only when the file count is more than one..but i couldnt able to get it coz in every iteration it takes only one one file

Re: file count

Hi Elma_ann
The problem is that you still have your second Iterate (Iterate2).
Connect the tFileList straight to tjava5 using the if statement.
tFileList--iterate->yourjob
|
if
|
tJava_5

As shown below:

Re: file count

Ok i see the problem
Your job is set up as follows:
tFilelist1 --Iterate-->fileinput
|
iterate 2
|
tjava3 --if--> tjava5

It needs to be (Do not have a second iterate):
tFilelist1 --Iterate-->fileinput
|
if
|
tjava5
see screenshot attached

Re: file count

Ok i see the problem
Your job is set up as follows:
tFilelist1 --Iterate-->fileinput
|
iterate 2
|
tjava3 --if--> tjava5

It needs to be (Do not have a second iterate):
tFilelist1 --Iterate-->fileinput
|
if
|
tjava5
see screenshot attached
One Star

Re: file count

How can we get total number of records in all files. ex: if i have 5 files each having 20,20,20,20,10 records in each file. I want to assign values in one context variable as 90.
all files are at window directory.