Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

Tags (4)
6 Replies
Not applicable

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

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 agoSmiley Happy

Xue Bin

Not applicable

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

Hi all,

Have you been able to solve this issue?

If yes, could you share the solution?

Thanks in advance!

Tom

chiragpradhan
Contributor

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

Hi Gabriela,

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

Regards

Not applicable

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

Hi Pradhan,

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

chiragpradhan
Contributor

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

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
Contributor

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

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

Community Browser