Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

stabben23
Honored Contributor

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
Valued Contributor III

Re: For loop with date in filename

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

2 Replies
marcus_malinow
Valued Contributor III

Re: For loop with date in filename

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
Honored Contributor

Re: For loop with date in filename

Thanks Marcus,

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

Community Browser