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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Loop through Directory files

Hi ,
I want to compare a list from text file to directory folder name using tLoop.
would like to put list in array where folder is missing in a directory. so from below example- 00003 is missing and want to put this into array until I complete looking into directory and then print message
for example: text file data looks like: 00001, 00002 ,00003
 and directory folder: 00001
                             00002
                             00004
      Thanks,
Labels (2)
9 Replies
Anonymous
Not applicable
Author

Hello 
I don't understand your problem well, however, you can use tFileList to iterate all files or folders in a specified directory, there are some global variables that store the current file name or file path are available on this component. 
Regards
Shong
Anonymous
Not applicable
Author

ok, I have a text file which has list of folder names, I want to make sure those folder still exists in directory.
I want to look at text file, loop through directory folder and add missing folder to list of array.
text file looks like ;
0001
0002
0003
0004
Directory folders look like:
0001
0002
0004
I want to list missing folder which is 0003.
Thanks,
Anonymous
Not applicable
Author

Hello 
You need to do an inner job on tMap and get the reject lines which are the missing folders, the job looks like:
tFileInputDelimited--main--tMap---main-->tlogrow
                                          |
                                      lookup
                                          |
 tFileList--iterate--tfixedFlowInput--main--tUnite
tFileInpuDelimted: read the text file
tFileList: iterate all the folders
tfixedFlowInput: generate the current folder name using the global variable ((String)globalMap.get("tFileList_1_CURRENT_FILE"))
About how to do an inner join and get unmatched rows, please refer to this article.
Regards
Shong
Anonymous
Not applicable
Author

Thanks for your help on this.
I would like to use tLoop and Global variable to achieve this.
Please help.
Anonymous
Not applicable
Author

List your directories in a text file and read it using tFileInputDelimited; you only have one column.
Connect this to tFlowToIterate, and then iterate to tJava. You can perform any initialisation you want in the tJava.
tFileInputDelimited_1(row1)->tFlowToIterate_1(Iterate)->tJava_1
Unfortunately, you can't natively create a directory with Talend, so you need to touch a file in the (new) directory (and create directory if it does not exist). You can then remove the file.
From tJava_1(OnSubJob)->tFileTouch_1(OnSubJobOK)->tFileDelete_1
Anonymous
Not applicable
Author

thanks for quick reply.
So my tFileInputDelimited has list of directory. and my directory has a list of folders
for example: text file data looks like: 00001, 00002 ,00003,00004,00005
 and directory folder: 00001, 00002, 00005
I want to put 0003 and 0004 into a list of array since these two are missing folders in directory structure.
Anonymous
Not applicable
Author

I thought I had it and you lost me ;-)
A directory is a folder.
In my example, I did forget to include the important test tFileExists_1 to see if the directory exists, before creating it.
If you want to list the directories rather than create, connect tFileExists(NotExists)->tJava and use System.out.println() to print them.
If you really need then in an array, add them in tJava.
Anonymous
Not applicable
Author

I Had a multiple Records in the Input ( Customer ID, Name, Amount) and I want to Display the output like "If their is any same customer ID's and I want  to print the all the Amounts in One Record, is That Possible if it Is which function Can I Use in Data Mapper? 
_AnonymousUser
Specialist III
Specialist III

I Had a multiple Records in the Input ( Customer ID, Name, Amount) and I want to Display the output like "If their is any same customer ID's and I want  to print the all the Amounts in One Record, is That Possible if it Is which function Can I Use in Data Mapper? 

Hi,
Could you provide us with an input file example and the expected output file ?
Eric