<?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 How to skip empty folder in a For-Next loop in load scrip in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-to-skip-empty-folder-in-a-For-Next-loop-in-load-scrip/m-p/1749802#M64136</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using the the following script to load files within folder name with dates. Users will upload the files when there is new files made available. There are instances that users will leave empty folder with no file in it, and the QS will show the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;'Cannot open file: 'lib://QSD/20200801/Report*.xls'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Here is my load script.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FOR Each vDir in DirList('$(vDataPath)/*')&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; Table:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; LOAD Distinct&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TRIM(Mid(filebasename(), 16)) as Products,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; FileTime() as ReportTime,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Floor(FileTime())) as ReportDate,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MonthName((Floor(FileTime()))) as MonthYear,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year(FileTime())*12+Month(FileTime()) as ReportYearMonthKey,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/162068"&gt;@13&lt;/a&gt; as SpecID,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @2 as MatlNumber,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @3 as MatlDescription,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/284384"&gt;@14&lt;/a&gt; as "Spec. Type"&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; FROM [$(vDir)/Report*.xls] (biff, no labels, header is 10 lines)&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; Where &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/284384"&gt;@14&lt;/a&gt;='MAT_PART_E';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Next&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The directory structure is as follow, and there are .xls file within each folder to be loaded into QS.&lt;/P&gt;&lt;P&gt;10/06/2020&amp;nbsp; 08:42 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;BR /&gt;10/06/2020&amp;nbsp; 08:42 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;BR /&gt;10/06/2020&amp;nbsp; 08:42 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200801&lt;BR /&gt;08/05/2020&amp;nbsp; 08:58 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200805&lt;BR /&gt;08/07/2020&amp;nbsp; 01:09 PM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200807&lt;BR /&gt;08/12/2020&amp;nbsp; 11:13 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200812&lt;BR /&gt;08/13/2020&amp;nbsp; 06:01 PM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200813&lt;/P&gt;&lt;P&gt;How can the script be updated with a logic to check empty folder and if it is an empty folder then&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;If it is the last folder, end the loop&lt;/LI&gt;&lt;LI&gt;If it it not the last folder, skip it and go to the next folder.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thank you in advance for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 18:00:50 GMT</pubDate>
    <dc:creator>A7R3</dc:creator>
    <dc:date>2024-11-16T18:00:50Z</dc:date>
    <item>
      <title>How to skip empty folder in a For-Next loop in load scrip</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-skip-empty-folder-in-a-For-Next-loop-in-load-scrip/m-p/1749802#M64136</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using the the following script to load files within folder name with dates. Users will upload the files when there is new files made available. There are instances that users will leave empty folder with no file in it, and the QS will show the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;'Cannot open file: 'lib://QSD/20200801/Report*.xls'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Here is my load script.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FOR Each vDir in DirList('$(vDataPath)/*')&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; Table:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; LOAD Distinct&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TRIM(Mid(filebasename(), 16)) as Products,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; FileTime() as ReportTime,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Floor(FileTime())) as ReportDate,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MonthName((Floor(FileTime()))) as MonthYear,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year(FileTime())*12+Month(FileTime()) as ReportYearMonthKey,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/162068"&gt;@13&lt;/a&gt; as SpecID,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @2 as MatlNumber,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @3 as MatlDescription,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/284384"&gt;@14&lt;/a&gt; as "Spec. Type"&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; FROM [$(vDir)/Report*.xls] (biff, no labels, header is 10 lines)&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; Where &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/284384"&gt;@14&lt;/a&gt;='MAT_PART_E';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Next&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The directory structure is as follow, and there are .xls file within each folder to be loaded into QS.&lt;/P&gt;&lt;P&gt;10/06/2020&amp;nbsp; 08:42 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;BR /&gt;10/06/2020&amp;nbsp; 08:42 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;BR /&gt;10/06/2020&amp;nbsp; 08:42 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200801&lt;BR /&gt;08/05/2020&amp;nbsp; 08:58 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200805&lt;BR /&gt;08/07/2020&amp;nbsp; 01:09 PM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200807&lt;BR /&gt;08/12/2020&amp;nbsp; 11:13 AM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200812&lt;BR /&gt;08/13/2020&amp;nbsp; 06:01 PM&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DIR&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20200813&lt;/P&gt;&lt;P&gt;How can the script be updated with a logic to check empty folder and if it is an empty folder then&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;If it is the last folder, end the loop&lt;/LI&gt;&lt;LI&gt;If it it not the last folder, skip it and go to the next folder.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thank you in advance for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 18:00:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-skip-empty-folder-in-a-For-Next-loop-in-load-scrip/m-p/1749802#M64136</guid>
      <dc:creator>A7R3</dc:creator>
      <dc:date>2024-11-16T18:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to skip empty folder in a For-Next loop in load scrip</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-skip-empty-folder-in-a-For-Next-loop-in-load-scrip/m-p/1749813#M64137</link>
      <description>&lt;P&gt;You could try to loop through the files within each folder as well as each folder. Try the script below.&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;FOR Each vDir in DirList('$(vDataPath)/*')&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FOR each vFile in filelist (vDir&amp;amp;'\*.xls' )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Table:&lt;/P&gt;&lt;P&gt;LOAD Distinct&lt;BR /&gt;TRIM(Mid(filebasename(), 16)) as Products,&lt;BR /&gt;FileTime() as ReportTime,&lt;BR /&gt;Date(Floor(FileTime())) as ReportDate,&lt;BR /&gt;MonthName((Floor(FileTime()))) as MonthYear,&lt;BR /&gt;Year(FileTime())*12+Month(FileTime()) as ReportYearMonthKey,&lt;BR /&gt;@13 as SpecID,&lt;BR /&gt;@2 as MatlNumber,&lt;BR /&gt;@3 as MatlDescription,&lt;BR /&gt;@14 as "Spec. Type"&lt;BR /&gt;FROM &lt;STRONG&gt;[$(vFile)]&lt;/STRONG&gt; (biff, no labels, header is 10 lines)&lt;BR /&gt;Where @14='MAT_PART_E';&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Next vFile&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Next&amp;nbsp;&lt;STRONG&gt;vDir&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2020 03:38:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-skip-empty-folder-in-a-For-Next-loop-in-load-scrip/m-p/1749813#M64137</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2020-10-06T03:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to skip empty folder in a For-Next loop in load scrip</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-skip-empty-folder-in-a-For-Next-loop-in-load-scrip/m-p/1750202#M64138</link>
      <description>&lt;P&gt;Hi Vegar,&lt;/P&gt;&lt;P&gt;Thank you. It works nicely.&lt;/P&gt;&lt;P&gt;Regards, Ernest&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 06:13:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-skip-empty-folder-in-a-For-Next-loop-in-load-scrip/m-p/1750202#M64138</guid>
      <dc:creator>A7R3</dc:creator>
      <dc:date>2020-10-07T06:13:30Z</dc:date>
    </item>
  </channel>
</rss>

