Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
New Contributor III

Load Multiple (only selected) Files, with condition

Hi,

I need help with this small problem. I have folder with list of qvd files:

dbf_pm201611

dbf_pm201612

dbf_pm201701

dbf_pm201702

dbf_pm201703

I usually use this code to trace all folder files and put them into one qvd file:

For Each vFile in FileList ('D:\DW\data_qvd\dbf_pm\dbf_pm*.qvd')

    TRACE $(vFile);   

   

    Files:

    LOAD

        '$(vFile)' as File

    AutoGenerate 1;   

NEXT vFile

LET vRows = NoOfRows('Files');

PM:

LOAD * INLINE [

    [REG]

];

For i = 0 to vRows - 1

    LET vFile = Peek('File', i, 'Files');

    TRACE $(vFile) ;

    Concatenate (PM)

    LOAD DATE(DATE#(DATUM,'DD/MM/YYYY'),'DD-MM-YYYY') as FDATUM,

    *

    FROM

    [$(vFile)](qvd);

Next i

STORE PM into D:\DW\poh.qvd(qvd);

   

//DROP Table Subory;

SET i = ;

SET vFile = ;

SET vRows = ;

And now I need condition wich can load only files from for example:

dbf_pm201701

dbf_pm201702

dbf_pm201703

Tags (1)
1 Solution

Accepted Solutions
Highlighted

Re: Load Multiple (only selected) Files, with condition

Hi Ján,

Here is my version of code.

PM:

LOAD * INLINE [

    REG

];

For Each vFile in FileList ('D:\DW\data_qvd\dbf_pm\dbf_pm*.qvd')

IF '$(vFile)' like '*' & Year(Today()) & '*' THEN

    TRACE $(vFile) ;

    Concatenate (PM)

    LOAD DATE(DATE#(DATUM,'DD/MM/YYYY'),'DD-MM-YYYY') as FDATUM,

    *

    FROM

    [$(vFile)](qvd);

END IF

NEXT vFile

STORE PM into D:\DW\poh.qvd(qvd);

 

SET vFile = ;

View solution in original post

5 Replies
Highlighted

Re: Load Multiple (only selected) Files, with condition

May be this

For Each vFile in FileList ('D:\DW\data_qvd\dbf_pm\dbf_pm*.qvd')

    TRACE $(vFile); 

 

    Files:

    LOAD

        '$(vFile)' as File,

       Date#(KeepChar('$(vFile)', ,0123456789'), 'YYYYMM') as Date

    AutoGenerate 1; 

NEXT vFile

FinalFiles:

LOAD File

Resident Files

Where Year(Date) = Year(Today());

DROP Table Files

LET vRows = NoOfRows('Files');

PM:

LOAD * INLINE [

    [REG]

];

.

.

.

Highlighted
Honored Contributor

Re: Load Multiple (only selected) Files, with condition

Hi,


I leaned your code out a little for you, this is obviously an example which you can work from (hopefully) but if you want any changes then let me know?

For Each vFile in FileList ('D:\DW\data_qvd\dbf_pm\dbf_pm*.qvd')

  

   if WildMatch('$(vFile)','*2017*')>0 THEN

   TRACE loading: $(vFile); 

    PM:

LOAD DATE(DATE#(DATUM,'DD/MM/YYYY'),'DD-MM-YYYY') as FDATUM,

    *

    FROM

    [$(vFile)](qvd);

  ELSE

  TRACE ignoring: $(vFile); 

  endif

Next vFile

STORE PM into .\poh.qvd(qvd);

  

//DROP Table Subory;

SET i = ;

SET vFile = ;

SET vRows = ;

Highlighted

Re: Load Multiple (only selected) Files, with condition

Hi Ján,

Here is my version of code.

PM:

LOAD * INLINE [

    REG

];

For Each vFile in FileList ('D:\DW\data_qvd\dbf_pm\dbf_pm*.qvd')

IF '$(vFile)' like '*' & Year(Today()) & '*' THEN

    TRACE $(vFile) ;

    Concatenate (PM)

    LOAD DATE(DATE#(DATUM,'DD/MM/YYYY'),'DD-MM-YYYY') as FDATUM,

    *

    FROM

    [$(vFile)](qvd);

END IF

NEXT vFile

STORE PM into D:\DW\poh.qvd(qvd);

 

SET vFile = ;

View solution in original post

Highlighted
Esteemed Contributor II

Re: Load Multiple (only selected) Files, with condition

Here is my version !

let vFiles = 'D:\DW\data_qvd\dbf_pm\dbf_pm'&Year(Today());

FACT:

Load *

From '$(vFiles)'*.QVD;

Highlighted

Re: Load Multiple (only selected) Files, with condition

I like this