Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
kris_vliegen
Partner - Creator III
Partner - Creator III

Read file if exist - variable file-name

Hi All,

Is it possible in Qlikview to check if a csv-file is in a map and if it is, Qlikview should read this file.

The filename of the csv file is variable. It always starts with Time and a date.

Time20161215.csv, Time20161214, ...

Is it possible that if a file with Time*.csv exist I read all the Time*.csv files.

Can I make this script variable? Like

IF (NOT isNull(qvdCreateTime('..\\FileLocation\Time*.csv'))) THEN

But this isn't working.

This is what I have, but the first line in the script should be variable.

IF (NOT isNull(qvdCreateTime('..\\FileLocation\Time20161215.csv'))) THEN

Time:

Load  @1 as Number,

         @2 as Name

FROM

[..\\FileLocation\Time*.csv]

(txt, codepage is 1252, explicit labels, delimiter is ';', header is 1 lines);

END IF;

Regards,

Kris

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Use a simple loop:

For each vFile in FileList('..\\FileLocation\Time*.csv')

     Time:

     LOAD

          @1 as Number,

          @2 as Name

     FROM

          [$(vFile)] (txt, codepage is 1252, explicit labels, delimiter is ';', header is 1 lines)

          ;

Next

If there are no csv files there then nothing will be loaded without any error being generated.


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

Use a simple loop:

For each vFile in FileList('..\\FileLocation\Time*.csv')

     Time:

     LOAD

          @1 as Number,

          @2 as Name

     FROM

          [$(vFile)] (txt, codepage is 1252, explicit labels, delimiter is ';', header is 1 lines)

          ;

Next

If there are no csv files there then nothing will be loaded without any error being generated.


talk is cheap, supply exceeds demand
Anonymous
Not applicable

use the variable to capture the time and date.

kris_vliegen
Partner - Creator III
Partner - Creator III
Author

Thanx Gysbert,

This works!