Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to take latest csv file from the folder

Hi All,

Every hour i am receiving one new file .I need to pick the latest file for loading .

I am thinking two ways to do

1.Moving the file to Archive folder once it is loaded

2.Picking the latest file based on system date .

Please suggest me which way is better ans how to do in Qlikview .

Thanks,

Rahul

1 Solution

Accepted Solutions
maxgro
MVP
MVP

alltxtfiles:

load distinct

  FileName() as fn,

  FileTime() as ft

FROM *.csv;

lasttxtfile:

First 1

load fn as lastfn, ft as lastft

Resident alltxtfiles

order by ft desc;          // desc for last, asc for sirst

View solution in original post

5 Replies
anbu1984
Master III
Master III

jonasheisterkam
Partner - Creator III
Partner - Creator III

You can use both, to look at the filestamp protects you if youre script runs on a problem for a houre or youre qv-service is down and on the next run there are two files.

CSV-Files use lot of space, if you dont use it any more you can at it to a compressed filecontainer. With execute you can use some applications like seven zip.

jonasheisterkam
Partner - Creator III
Partner - Creator III

You find some code in the help of "for each ... next" , "filetime" and "execute"

maxgro
MVP
MVP

alltxtfiles:

load distinct

  FileName() as fn,

  FileTime() as ft

FROM *.csv;

lasttxtfile:

First 1

load fn as lastfn, ft as lastft

Resident alltxtfiles

order by ft desc;          // desc for last, asc for sirst

Anonymous
Not applicable
Author

you can read files from the directory and check the latest date/time with the function - filetime( 'file' )