Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
yura_ratu
Partner - Creator II
Partner - Creator 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
daveamz
Partner - Creator III
Partner - Creator III

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

View solution in original post

6 Replies
daveamz
Partner - Creator III
Partner - Creator III

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
Partner - Creator II
Partner - Creator II
Author

Hello David

Could you please explain what Peek function does here.

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

Currently in variables overview vFileNames is empty

maxgro
MVP
MVP

daveamz
Partner - Creator III
Partner - Creator III

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
Specialist II
Specialist II

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

daveamz
Partner - Creator III
Partner - Creator III

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