Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
svsudhakar
Creator
Creator

Load Stmt

Hi ,

need help on below issue

I have multiple QVD's each qvd column count is different .

EX:

In QVD1 I have 2 columns

Col A and Col B

In Qvd2 I have 3 columns

Col A ,Col B and Col C

I used script to load all QVD like

Test:

Load A,

B,

C

From Data\*.QVD;

now its giving error because Col C is not available in 1st QVD. please suggest is there any possibility to load the data in single Load stmt.

I know if i use concat I can achieve this but like this I have multiple Qvd's with different formats.

6 Replies
pokassov
Specialist
Specialist

Hello!

Load * from....

mrossoit
Creator II
Creator II

set n = 0;

sub DoDir (Root)

        for each File in filelist (Root&'\*.qvd')

               n = n + 1;

               QVD_$(n):

               load * from $(File);

        next File

    for each Dir in dirlist (Root&'\*' )

        call DoDir (Dir)

    next Dir

end sub

call DoDir ('$(my_directory)')

jonathandienst
Partner - Champion III
Partner - Champion III

I assume you want all the QVDs to be loaded into a single table. With different field lists, you will get mutiple tables and a messy composite key. I suggest that you load them in a loop and explicitly concatenate them:

     Set vHeader = 'DataTable:';

     ForEach vFile in FileList(Data\*.QVD)

          $(vHeader )

          LOAD * FROM [$(vFile)] (qvd);

          Set vHeader = 'Concatenate(DataTable)';

     Next

The vHeader settings concatenate all the files after the first one into the same table.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jagan
Luminary Alumni
Luminary Alumni

Hi Sudhakar,

You can use For loop to loop through each file in the directory and force concatenate all the tables.  You can follow the script provided by jontydkpi.

Regards,

Jagan.

svsudhakar
Creator
Creator
Author

Hi Jonathan,

Thanks for your reply ..

can u please share the QVW file.

jonathandienst
Partner - Champion III
Partner - Champion III

Sorry, I cannot upload files from here due to client's security policy. Just use the script I posted as is. It will load the contents of all the QVD files matching the FileList parameter into the [DataTable] table.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein