Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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!
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