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: 
dukane24
Contributor III
Contributor III

Load a file with a constantly changing name


We have an automatically generated file that gets stored in a folder dated for the current date each Monday in mm-dd-yy format, let's call it "Report - 12-29-14.xlsx".  It gets stored in a folder with the same date so, "Z:\12-29-14\Report - 12-29-14.xlsx".

Would it be possible to write a load script that:

A. Looks for a file always dated for the Monday prior

or

B. Will loop through folders & files to find the newest folder and or file with a certain naming format?

Thanks for your help!

2 Replies
Not applicable

Try something like this:

SET DateFormat='MM-DD-YYYY';       // NEEDED IN CASE YOU USE ANOTHER DATE FORMAT BY DEFAULT

// -1 IS FOR PREVIOUS WEEK'S MONDAY, DELETE IF YOU WANT *THIS* MONDAY

Let v_PreviousMonday = MakeWeekDate(Year(Today()), Week(Today())-1);

// CREATE FILE NAME AS A VARIABLE TO BE USED IN A LATER LOAD STATEMENT

Let vFileName = 'Z:\$(v_PreviousMonday)\Report - $(v_PreviousMonday).xlsx';

Load *

from [$(vFileName] .....

Hope this helps!

maxgro
MVP
MVP

A

=date(WeekStart(today())-7, 'MM-DD-YY')

B

maybe you can start here:

in Qlik online help, look for (index tab)

for each..next

and you'll find an example of loop on folders and files