Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I Need to take a csv file from an FTP to integrate on my qlikview model, the problem is that the file is generated every 2 hours with a different name and I need to identify which is the most up to date and take that to my load ... filetime () function returns me null, someone knows if there is another option to get this information?
Thank you very much in advance!
Gabriela
Hi Gabriela,
I'm facing with the same problem. Can you share with me the solution if you have solved it? Notice this thread is pretty long ago:)
Xue Bin
Hi all,
Have you been able to solve this issue?
If yes, could you share the solution?
Thanks in advance!
Tom
Hi Gabriela,
Have you tried using the full file path in the Filetime function rather than just the file name?
Regards
Hi Pradhan,
can you please post an example on how that should look?
Hi Tom,
Here is the complete solution. Create a sub with the below code.
/************************************************************/
SUB GetLatestFile(Folder,Mask,OutputVariable)
FOR EACH FoundFile in FileList(Folder & Mask)
FileList:
LOAD
SubField('$(FoundFile)','\',-1) AS FileName, FileTime('$(FoundFile)') AS DateTimeStamp
AutoGenerate 1;
NEXT FoundFile
IF NoOfRows('FileList') > 0 THEN
Variable:
LOAD
MAX(DateTimeStamp) , FileName AS $(OutputVariable)
RESIDENT FileList
GROUP BY FileName
ORDER BY DateTimeStamp;
LET $(OutputVariable) = Peek('$(OutputVariable)');
DROP TABLES FileList,Variable;
ENDIF;
ENDSUB;
/***********************************************************/
And call this in your app
CALL GetLatestFile('$(vFilePath)','*.csv','vMyLastestFile');
Hope it helps. If this is what you were looking for, please mark this thread as answered. Thank you.
Gabriela Fonseca Please look at the solution I provided above and mark the question answered if it helps.