Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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;
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
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