Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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 code 0683p000009M9p6.pngystem.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
Labels (3)
8 Replies
Anonymous
Not applicable
Author

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

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
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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:
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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
_AnonymousUser
Specialist III
Specialist III

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.