<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Check if another file exists - File name substring and append in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281573#M56055</link>
    <description>If I understand correctly there are two cases here: 
&lt;BR /&gt;1) some files exist, but no control file 
&lt;BR /&gt;2) all files exist. 
&lt;BR /&gt;so, using this job template: 
&lt;BR /&gt;tFileList--iterate--&amp;gt;tJava--onComponentOK--&amp;gt;tFileExist----OnSubjobOK---&amp;gt;(rest of job) 
&lt;BR /&gt;in the tJava: 
&lt;BR /&gt; 
&lt;PRE&gt;String fileName = globalMap.get("tFileList_1_CURRENT_FILEPATH");&lt;BR /&gt;&amp;lt;do something with fileName&amp;gt;&lt;BR /&gt;context.control_file = fileName;&lt;/PRE&gt; 
&lt;BR /&gt;in the tFileExist, check for the existence of: 
&lt;BR /&gt; 
&lt;PRE&gt;context.control_file&lt;/PRE&gt; 
&lt;BR /&gt;in the rest of your job, you can refer to the current file of the tFileList with: 
&lt;BR /&gt; 
&lt;PRE&gt;globalMap.get("tFileList_1_CURRENT_FILEPATH")&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Jun 2011 14:53:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-06-16T14:53:03Z</dc:date>
    <item>
      <title>Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281569#M56051</link>
      <description>Hi,
&lt;BR /&gt;I have a set of files shown like below.
&lt;BR /&gt;DAILY-USER-20110531-USERLOGON.xml
&lt;BR /&gt;DAILY-USER-20110531-USERLOGOFF.xml
&lt;BR /&gt;DAILY-USER-20110531-CONTROL.xml
&lt;BR /&gt;DAILY-USER-20110530-USERLOGON.xml
&lt;BR /&gt;DAILY-USER-20110530-CONTROL.xml
&lt;BR /&gt;I have a tFileList component with the source folder which is holding above files. Now for files ending with USERLOGON.xml, USERLOGOFF.xml, I need to check if its corresponding CONTROL.xml file exists with the initial part of the file name as same. As you can see there is a date 20110530, 20110531 which keeps changing. Now I wanted to try out the following ways..
&lt;BR /&gt;1. Get the file name string in a loop and substring it till the date (constant number of characters in this case 20) and append 'CONTROL.xml' to the string and pass it on to a tFileExist component.
&lt;BR /&gt;2. If the CONTROL.xml file exists then proceed with next operation on the original file processing.
&lt;BR /&gt;But I am not able to get the context variables or some other way to get this done.. I am new to Talend... can any body please help with possible easier ways. My Talend code generated is Java. Thanks in advance.</description>
      <pubDate>Sat, 16 Nov 2024 12:51:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281569#M56051</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T12:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281570#M56052</link>
      <description>you have the right idea.&lt;BR /&gt;use a tFileList to retrieve the list of files. in a tJava, retrieve the file names from the global map and prepare your context variable-- then use it to check if your control file exists. &lt;BR /&gt;so&lt;BR /&gt;tFileList--iterate--&amp;gt;tJava--onComponentOK--&amp;gt;tFileExist</description>
      <pubDate>Wed, 15 Jun 2011 15:34:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281570#M56052</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-15T15:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281571#M56053</link>
      <description>with tfilelist, the tfileexists doesnt seem to work when there is no file john.</description>
      <pubDate>Thu, 16 Jun 2011 07:03:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281571#M56053</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-16T07:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281572#M56054</link>
      <description>Is there a sample Java code, which can be used for the above purpose. My doubt is how can I say componentOK and pass the actual file name to next module after checking if corresponding CONTROL.xml exists in tJava?</description>
      <pubDate>Thu, 16 Jun 2011 10:34:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281572#M56054</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-16T10:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281573#M56055</link>
      <description>If I understand correctly there are two cases here: 
&lt;BR /&gt;1) some files exist, but no control file 
&lt;BR /&gt;2) all files exist. 
&lt;BR /&gt;so, using this job template: 
&lt;BR /&gt;tFileList--iterate--&amp;gt;tJava--onComponentOK--&amp;gt;tFileExist----OnSubjobOK---&amp;gt;(rest of job) 
&lt;BR /&gt;in the tJava: 
&lt;BR /&gt; 
&lt;PRE&gt;String fileName = globalMap.get("tFileList_1_CURRENT_FILEPATH");&lt;BR /&gt;&amp;lt;do something with fileName&amp;gt;&lt;BR /&gt;context.control_file = fileName;&lt;/PRE&gt; 
&lt;BR /&gt;in the tFileExist, check for the existence of: 
&lt;BR /&gt; 
&lt;PRE&gt;context.control_file&lt;/PRE&gt; 
&lt;BR /&gt;in the rest of your job, you can refer to the current file of the tFileList with: 
&lt;BR /&gt; 
&lt;PRE&gt;globalMap.get("tFileList_1_CURRENT_FILEPATH")&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jun 2011 14:53:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281573#M56055</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-16T14:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281574#M56056</link>
      <description>Thank you very much. But I am now facing error with context.control_file.&lt;BR /&gt;My tJava code is:&lt;BR /&gt;context.control_file = substring((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"),26);&lt;BR /&gt;This is giving error as 'The method substring(string, int) is undefined for the type &amp;lt;jobname&amp;gt;.&lt;BR /&gt;In tFileExist_1 -&amp;gt; I gave the file path as context.control_file in file name/stream.&lt;BR /&gt;This is giving error as ' control_file cannot be resolved or is not a field'.&lt;BR /&gt;What am I missing?</description>
      <pubDate>Fri, 17 Jun 2011 08:02:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281574#M56056</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-17T08:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281575#M56057</link>
      <description>1) context.control_file = ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")).substring(26); &lt;BR /&gt;2) you need to add control_file as a context variable in the context tab.</description>
      <pubDate>Fri, 17 Jun 2011 13:31:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281575#M56057</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-17T13:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281576#M56058</link>
      <description>Thank you very much John for patiently replying to all my questions. It seems to be working, but still there is one problem. Even if there is no corresponding CONTROL.xml file, it is copying all the files. I think it should be the problem with iteration.
&lt;BR /&gt;My tJava code:
&lt;BR /&gt;context.control_file = ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")).substring(0,69)+"CONTROL.xml"; 
&lt;BR /&gt;System.out.println( ((String)globalMap.get("tFileList_1_CURRENT_FILE")));
&lt;BR /&gt;System.out.println( context.control_file);
&lt;BR /&gt;My tFileExist file path:
&lt;BR /&gt;context.control_file
&lt;BR /&gt;I set a context variable. Please find the execution screenshot below.
&lt;BR /&gt;For me it should not copy files without corresponding CONTROL.xml, but irrespective of result of before steps, it is copying all files.</description>
      <pubDate>Fri, 17 Jun 2011 15:57:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281576#M56058</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-17T15:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281577#M56059</link>
      <description>instead of 'onComponentOK' you need to use an 'if' connector. click on the connector and in the 'if' component tab, you put the condition you want to check:&lt;BR /&gt;(Boolean)globalMap.get("tFileExists_EXISTS") &lt;BR /&gt;&lt;BR /&gt;check the generated code for the tFileExists component to make sure i'm giving you the correct key to the globalMap.</description>
      <pubDate>Sat, 18 Jun 2011 15:59:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281577#M56059</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-18T15:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Check if another file exists - File name substring and append</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281578#M56060</link>
      <description>Thank you very much John!!!
&lt;BR /&gt;That worked with ((Boolean)globalMap.get("tFileExist_1_EXISTS")) in If condition. This really helped me understand the flow. Thank you very much for your answers and patience. Where can I get these detailed set of components and their checks or example projects. I have gone through the tutorials provided with talend, but this in depth practical details are not available i guess. Thanks again.</description>
      <pubDate>Sun, 19 Jun 2011 08:25:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Check-if-another-file-exists-File-name-substring-and-append/m-p/2281578#M56060</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-19T08:25:30Z</dc:date>
    </item>
  </channel>
</rss>

