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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Browse folders and find identical files (without using tFileCompare)

HI,
I try to browse two folders and see if I find in the two, files with the same name (my files in my folders are named with an ID and I have to parse the file names and compare to see if I have this ID)
for exmaple :
File1=Toto1-12345.csv in folder 1
File2=Toto2-12345.csv in folder 2
Result OK : I have the same ID 12345

I can not use a tFileCompare because they come from two different systems (different moment, different filename, different ref....)
an idea how I could do?
I tried: tFileList_1----OnComponnentOk----tFileList_2------iterate------tJava. but it doesn't work. In my tJava I tried (if (String)globalMap.get("tFileList_1_CURRENT_FILE")==(String)globalMap.get("tFileList_2_CURRENT_FILE") ....)
Thanks
Labels (3)
9 Replies
alevy
Specialist
Specialist

Something like:
tFileList_1 --> tIterateToFlow (file names) --> tJavaRow (parse ID) --main--> tMap (inner join) -->
tFileList_2 --> tIterateToFlow (file names) --> tJavaRow (parse ID) --lookup-->
Anonymous
Not applicable
Author

Hi
In Java, use the method String1.equals("String2") to check one string if equlas to anther string. In your case, the expression should be:
(String)globalMap.get("tFileList_1_CURRENT_FILE").equals((String)globalMap.get("tFileList_2_CURRENT_FILE") ....))
Best regards
Shong
Anonymous
Not applicable
Author

Thanks both
I tried
Something like:
tFileList_1 --> tIterateToFlow (file names) --> tJavaRow (parse ID) --main--> tMap (inner join) -->
tFileList_2 --> tIterateToFlow (file names) --> tJavaRow (parse ID) --lookup-->

But impossible to retrieve my data from tJavaRow in my tMap.
alevy
Specialist
Specialist

tJavaRow just allows you to manipulate the row variables so there's no reason it shouldn't be available in tMap if you've done it properly. How about a screenprint?
Anonymous
Not applicable
Author

Thanks alevy,
maybe I'm wrong in setting my tJavarow 0683p000009MPcz.png
alevy
Specialist
Specialist

All you've done is declared a local variable. If you want the value passed out, the code should be something like row3.name_file=row1.filename;. (You can also use input_row and output_row instead of the actual row names.)
Anonymous
Not applicable
Author

works! thanks 0683p000009MACn.png
Anonymous
Not applicable
Author

please can any one tell me how to use tFileCompare
Anonymous
Not applicable
Author

Not sure how talend checks internally, but the tFileCompare performs the comparison for the contents inside the file on line by line basis... see the code below
while ((content_tFileCompare_1 = file_tFileCompare_1
.readLine()) != null
&& (contentRef_tFileCompare_1 = fileRef_tFileCompare_1
.readLine()) != null) {
if (content_tFileCompare_1
.compareTo(contentRef_tFileCompare_1) != 0) {
result_tFileCompare_1 = false;
break;
Refer to following URL for use case
https://help.talend.com/search/all?query=tFileCompare&content-lang=en
Thanks
Vaibhav