• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » if .... else on tFileList iteration

#1 2009-05-26 11:54:55

kzone
Member
Company: Synotis
Registered: 2008-07-06
Posts: 910
Website

if .... else on tFileList iteration

hi,

I have to check if some files exist ...
If file exist do something
if not (else) do something !

But flow 's never gone in "else" . (ps.odt doesn't exist !!)
conition I use :
if

Code:

((Boolean)globalMap.get("tFileExist_1_EXISTS"))

else

Code:

!((Boolean)globalMap.get("tFileExist_1_EXISTS"))

looks so simple , but didn't found solution !
thanks


Uploaded Images

Last edited by kzone (2009-05-26 11:59:16)


do Svg your graphical language !!!

Offline

#2 2009-05-26 12:12:17

shong
Talend team
Registered: 2007-08-29
Posts: 10297
Website

Re: if .... else on tFileList iteration

Hello

ps.odt doesn't exist !!)

As you said, the file doesn't exist, so the tFileList will not pass the file path of ps.odt to tFileExist, that means tFileExist don't check this file.

Best regards

          shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#3 2009-05-26 12:17:34

bcourtine
Member
Company: Alcion Group
Registered: 1970-01-01
Posts: 64
Website

Re: if .... else on tFileList iteration

I think it's normal : the tFileList components reads the real content of your folder. So only existing files matching the filemask will send be in the flow.

For your purpose you should replace your tFileList component by a tFileInputDelimited (containing a list of absolute paths) and next a tFlowToIterate.

Last edited by bcourtine (2009-05-26 12:19:30)


Java/J2EE and Talend certified consultant for Alcion Group.

Offline

#4 2009-05-26 13:01:58

kzone
Member
Company: Synotis
Registered: 2008-07-06
Posts: 910
Website

Re: if .... else on tFileList iteration

thanks to both of you,

files are in fact attachment part mail . I rename the file due to getFrom javamail's method and associated name
Sometimes partners change those values without telling us .In those case file keep the real "getfrom value" for naming file , but I don't know by advance which one.

I want to keep jobs and applications still running 'til the end for "the good ones" and take "the wrong ones" out of the flow!

So I can look after filename that I know with tFileList (with pattern)  and copy them somewhere else ... and it's why the reason for "else" smile

Perhaps parse twice the file list , first with pattern that I know, and another time with a pattern like "*.unknown" wherein "unknown" is the extension that i've added to unrecognized partners (getfrom value) !

laurent

ps : in the generated code there is

Code:

java.io.File file_tFileExist_1 = new java.io.File(
                            "/home/raulier/TALEND_TEST/"
                                    + ((String) globalMap
                                            .get("tFileList_1_CURRENT_FILE")));
                    if (!file_tFileExist_1.exists()) {
                        globalMap.put("tFileExist_1_EXISTS", false);
                    } else {
                        globalMap.put("tFileExist_1_EXISTS", true);
                    }

so boolean value exist for my  "if ...else" solution , isnt' it ?

nevermind , i'm going to test your solution bcourtine ...

Last edited by kzone (2009-05-26 13:14:37)


do Svg your graphical language !!!

Offline

#5 2009-05-26 13:42:28

kzone
Member
Company: Synotis
Registered: 2008-07-06
Posts: 910
Website

Re: if .... else on tFileList iteration

....

work fine with tFlowToIterate !!
I was looking "midi à 14 heures" or "to make a mountain out of a mole hill" at the end !

result

not exist so do something else ...
not exist so do something else ...
not exist so do something else ...
not exist so do something else ...
exist so do something ...

thanks a lot ...


Uploaded Images


do Svg your graphical language !!!

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » if .... else on tFileList iteration

Board footer

Powered by FluxBB