Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
stabben23
Partner - Master
Partner - Master

For loop with date in filename

Hi, I want to loop throug a folder With logfiles containing a date in filname.

I want to start Reading With the file that have start date 2017-08-21 to 2017-08-27 (end date).

The Variables contain correct date, problem is related to "for i", how should use "for i" here.

Filename is ex Brd_2017-08-21.txt

This is what I have done without success.

Let vThisWeekStart = date(WeekStart(today(1)));
Let vThisWeekEnd = date(WeekEnd(today(1)));

for i = '$(vThisWeekStart)'to '$(vThisWeekEnd)';

For each vFileName in Filelist ('\\1.1.1.1\folder\Brd_'& $(i) &'.txt')

  Table:
LOAD
*
From $(vFileName)
(
txt, codepage is 1252, no labels, delimiter is '\t', msq)
Next vFileName
Next i

1 Solution

Accepted Solutions
marcus_malinow
Partner - Specialist III
Partner - Specialist III

How about this:

Let vThisWeekStart = date(WeekStart(today(1)));

Let vThisWeekEnd = date(WeekEnd(today(1)));

for i = '$(vThisWeekStart)'to '$(vThisWeekEnd)';

LET vFileName = '\\1.1.1.1\folder\Brd_'& Date($(i), 'YYYY-MM-DD') &'.txt';

TRACE $(vFileName);

  Table:

LOAD

*

From $(vFileName)

(txt, codepage is 1252, no labels, delimiter is '\t', msq);

Next i

View solution in original post

2 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

How about this:

Let vThisWeekStart = date(WeekStart(today(1)));

Let vThisWeekEnd = date(WeekEnd(today(1)));

for i = '$(vThisWeekStart)'to '$(vThisWeekEnd)';

LET vFileName = '\\1.1.1.1\folder\Brd_'& Date($(i), 'YYYY-MM-DD') &'.txt';

TRACE $(vFileName);

  Table:

LOAD

*

From $(vFileName)

(txt, codepage is 1252, no labels, delimiter is '\t', msq);

Next i

stabben23
Partner - Master
Partner - Master
Author

Thanks Marcus,

Date($(i), 'YYYY-MM-DD') did the trick.