Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
yura_ratu
Contributor II

Loading files from filelist in .qvd

Hello

I have a list of filenames as a column in a qvd file. How can use them for importing data in a loop such as

FOR Each File in FileList ()

Thanks

1 Solution

Accepted Solutions
daveamz01
Contributor III

Re: Loading files from filelist in .qvd

Hello Yuriy,

FileNamesTable:

LOAD

      Concat(Chr(39)&filenames&Chr(39), ', ') as filenames

FROM ....

LET vFileNames = Peek('filenames', 0, 'FileNamesTable');

DROP TABLE FileNamesTable;

FOR Each vFile IN $(vFileNames)

    $(vFile):

    LOAD *

    FROM $(vFile);

   

NEXT vFile;

Best regards,

David

6 Replies
daveamz01
Contributor III

Re: Loading files from filelist in .qvd

Hello Yuriy,

FileNamesTable:

LOAD

      Concat(Chr(39)&filenames&Chr(39), ', ') as filenames

FROM ....

LET vFileNames = Peek('filenames', 0, 'FileNamesTable');

DROP TABLE FileNamesTable;

FOR Each vFile IN $(vFileNames)

    $(vFile):

    LOAD *

    FROM $(vFile);

   

NEXT vFile;

Best regards,

David

yura_ratu
Contributor II

Re: Loading files from filelist in .qvd

Hello David

Could you please explain what Peek function does here.

LET vFileNames = Peek('filenames', 0, 'FileNamesTable');

Currently in variables overview vFileNames is empty

MVP
MVP

Re: Loading files from filelist in .qvd

daveamz01
Contributor III

Re: Re: Loading files from filelist in .qvd

For using

FileNamesTable:

LOAD

      Concat(Chr(39)&filenames&Chr(39), ', ') as filenames

FROM ....

you should get a table named 'FileNamesTable' with only 1 row containing values field 'filenames' concatenated like 'Field1', 'Field2', 'Field...'

peek function gets the value of this row and put it into vFileNames variable.


Because, you have 2 identical tables, QlikView auto-concatenate them and that's the reason your peek function doesn't work.


Here, I attached an example.


Best regards,

David

nizamsha
Valued Contributor

Re: Loading files from filelist in .qvd

u will excatly get  what u want only specify the ur path location in the path location path

For each file in Filelist( 'pathLocation\*.qvd')

Load *,

'$(file)' as FileName,

Floor( FileSize('$(file)')/1024) as FileSize,

SubField( '$(file)','\',-1) as FileType

  From [$(file)];

  Next file

daveamz01
Contributor III

Re: Loading files from filelist in .qvd

Yes, but sometimes you want to load a list of SQL table names to extract data in a loop. For dimension tables for instance.

David

Community Browser