Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Only load latest file

I am using the script below for incremental loading of files copied out to a shared drive and it works great.

I want to change this code to only load the latest file for another application I am working on.  Any suggestions how I can determine which file is the most recent?  I did not write this code, I got this from the community some time back.

//Creates current table  of excel files in the directory for incremental loading to compare to existing

TRACE DoDir;

SUB DoDir (Root) 

     FOR Each File in FileList(Root&'$(vSourceFile)') 

     Files: 

     LOAD '$(File)' as File_Name

     AutoGenerate 1; 

   NEXT File 

ENDSUB 

CALL DoDir (vRoot) 

Trace Loop;

FOR i=0 to NoOfRows('Files')-1  

   LET vFileName = Peek('File_Name', 0, 'Files'); 

   IF Date(Date#(SubField(vFileName, '_', 4), 'DD-MMM-YYYY')) >= vDateFrom and Date(Date#(SubField(vFileName, '_', 5), 'DD-MMM-YYYY')) <= vDateTo then 

      AppExtracts: 

      LOAD * 

      From [$(vRoot)\$(vFileName)] ; 

   ENDIF 

NEXT i; 

11 Replies
vikasmahajan

Thanks Marcus

Please can you go through my thread Load excel files dynamic and check whether excel file is changed or modify if yes load into qvd

Whether I can use this script for my purpose.

Thanks again

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
marcus_sommer

If you each xls stores as qvd then will be the suggestion from pcammaert suitable. If you stores all xls in one qvd then you need to store the filenames and filetimes within these qvd. You will need in both cases a loop through your folders/files and checking these parameter to skip the files if they are unchanged or to drop and load again these data/files.

- Marcus