Set-Item wsman:\localhost\Client\TrustedHosts serverName -Concatenate -Force
I needed to load the most recent file to load datas in a qlikview app.
My problem was that the most recent file was not based on date time of the file but based with the name of the file.
Goal is to load data and sort them desc and return only the first record, so i get the most recent file.
Sub DoDir (Root)
// filetype to search for in current directory, assuming files are excel type (.xls)
For Each Ext In 'xls'
For Each File In FileList (Root & '\YOUR FOLDER NAME*.' & Ext)
Files:
Load '$(File)' as Name
//if you want to sort by file date time uncomment next line and adapt loop
//FileTime('$(File)') as FileTime,
RangeSum(Peek('FileCount'), 1) as FileCount
Autogenerate 1;
Next File
Next Ext
/*
// search in subdirectories, uncomment if needed (recursive loop)
For Each Dir In DirList (Root & '\*')
Call DoDir (Dir)
Next Dir
*/
End Sub
//Call the fucntion DoDir with the path to the folder to be scanned
Call DoDir ('CHANGE TO YOUR FOLDER PATH THAT WILL BE SCANNED');
//load
MostRecentFileName:
FIRST 1 LOAD Name AS MostRecentFileName
RESIDENT Files
ORDER BY Name DESC;
LET vFileToLoad = FieldValue('MostRecentFileName', 1);
//load datas to be used in your QlikView app
LOAD * FROM $(vFileToLoad)(your source parameters);