One Star

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
9 REPLIES
Seven Stars

Re: Browse folders and find identical files (without using tFileCompare)

Something like:
tFileList_1 --> tIterateToFlow (file names) --> tJavaRow (parse ID) --main--> tMap (inner join) -->
tFileList_2 --> tIterateToFlow (file names) --> tJavaRow (parse ID) --lookup-->
Community Manager

Re: Browse folders and find identical files (without using tFileCompare)

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
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Browse folders and find identical files (without using tFileCompare)

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.
Seven Stars

Re: Browse folders and find identical files (without using tFileCompare)

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?
One Star

Re: Browse folders and find identical files (without using tFileCompare)

Thanks alevy,
maybe I'm wrong in setting my tJavarow Smiley Sad
Seven Stars

Re: Browse folders and find identical files (without using tFileCompare)

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.)
One Star

Re: Browse folders and find identical files (without using tFileCompare)

works! thanks Smiley Happy
One Star

Re: Browse folders and find identical files (without using tFileCompare)

please can any one tell me how to use tFileCompare
Four Stars

Re: Browse folders and find identical files (without using tFileCompare)

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