Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can i obtain the time of a file in a ftp server

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

6 Replies
Not applicable
Author

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

Not applicable
Author

Hi all,

Have you been able to solve this issue?

If yes, could you share the solution?

Thanks in advance!

Tom

ChiragPradhan
Creator II
Creator II

Hi Gabriela,

Have you tried using the full file path in the Filetime function rather than just the file name?

Regards

Not applicable
Author

Hi Pradhan,

can you please post an example on how that should look?

ChiragPradhan
Creator II
Creator II

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.

ChiragPradhan
Creator II
Creator II

Gabriela Fonseca Please look at the solution I provided above and mark the question answered if it helps.