Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

pick the latest file ?

Hi togehter,

i want to load the latest csv file in my script and dont know how i realize it. How can i pick up the latest file from this Folder ?

In this case it would be the file "28779_2010-12-27.csv"

28779_2010-12-24.csv
28779_2010-12-25.csv
28779_2010-12-26.csv
28779_2010-12-27.csv

Thank you very much !

6 Replies
Not applicable
Author

First i would create a table with all files sorted byt their date:

first(1)

LOAD

ffilepath() as FileName,

filetime() as [Date File]

from

xxx\*.csv

order by filetime() DESC;

Then you take the name of the file

LET FileName = peek( 'FileName',0);

xxxx:

LOAD * FROM '$(FileName)';

Rgds,

Sébastien

Not applicable
Author

Hi Sebastien,

thank you but the editor does not accept this part ... ORDER BY FileTime() DESC;

FileTime() is red marked ! Did something missed ?

Thank you !

Not applicable
Author

here the code

FILESELEKTOR:
LOAD

FilePath() AS FileName,
FileName() AS DateFile

FROM H:\Qlikview Workspace\APILoader\reports\28779*.csv (utf8, txt, delimiter is ';', no labels, msq, header is 1 lines ) ORDER BY FileTime([FileName]) DESC;

LET FileName = peek('FileName',0);

Is that korrekt ? Thank you very much !

Not applicable
Author

nobody an idea ?

Not applicable
Author

Directory;

TEMP:

LOAD *,

filetime()                                           as file_time,

filepath()                                           as file_path,

filebasename()                                       as z_file,

timestamp(filetime())                                as time_stamp

FROM [Data\*.xls] (biff, embedded labels, table is Sheet1$);

left join (TEMP)

load

max(timestamp(file_time))                             as max_time

resident TEMP;

FINAL:

LOAD *, 1 as flag

resident TEMP where time_stamp=max_time;

drop table TEMP;

Not applicable
Author

Clipboard01.png