Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rnepla83
Partner - Creator
Partner - Creator

concatenate in a loop

Hi to all,

Is possible to generate a loop of concatenate, that concatenate the content of some qvd’s files?

Will follow an example:

Suppose that I have a field in my database that is:

FIELD: {A,B,C,D}

And suppose that I have 4 qvd’s file:

- fileA.qvd

- fileB.qvd

- fileC.qvd

- fileD.qvd

I need to find a way to generate an automatic iteration that generate code like the one below:

Load *

from  fileA.qvd

concatenate

Load *

from  fileB.qvd

concatenate

Load *

from  fileC.qvd

concatenate

Load *

from  fileD.qvd

Can you give me an example of concatenate in a loop?

Set NFiles = 4;
for i = 1 to $(NFiles-1)

…………….  

Next

In this sample there are 4 files. In my final qvw will be more than 100 qvd that will be concatenated.

So I need to find a script that generate automatically the concatenate of those files.

Thank you for supporting me.

Paolo

1 Solution

Accepted Solutions
Gysbert_Wassenaar

That sounds like a very bad idea. Your table will look like this:

A     B     C     D

3     -     -     -

4     -     -     -

1     -     -     -

-     1     -     -

-     5     -     -    

-     2     -     -    

-     -     3     -    

-     -     1     -

-     -     6     -

-     -     -     2

-     -     -     1

-     -     -     2

etc...

If that's really what you want try this:

Result:

LOAD * INLINE ;

FOR EACH vFile in FileList('C:\QVDATA\*.qvd')

            CONCATENATE

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

NEXT vFile


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

That sounds like a very bad idea. Your table will look like this:

A     B     C     D

3     -     -     -

4     -     -     -

1     -     -     -

-     1     -     -

-     5     -     -    

-     2     -     -    

-     -     3     -    

-     -     1     -

-     -     6     -

-     -     -     2

-     -     -     1

-     -     -     2

etc...

If that's really what you want try this:

Result:

LOAD * INLINE ;

FOR EACH vFile in FileList('C:\QVDATA\*.qvd')

            CONCATENATE

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

NEXT vFile


talk is cheap, supply exceeds demand
rnepla83
Partner - Creator
Partner - Creator
Author

Hi Gysbert ,

thanks a lot, works perfectly.

I know that is a bad idea but i think is the only one possibility to concatenate qvd's.

1. The loading will be from one table that contain all the datas. (qv_file: LOAD * FROM Table where code = var)

2. With multi-tasking scheduling we run many task of the same qv_file with a parameter (variable).

(in a command line will be: run qv_file /vvar=001,

in another command line will be: run qv_file /vvar=002

......

)

In this way we got all the data filtered with this variable, to have many qvd's that are called with a name of such variable. (qv_file_001.qvd, qv_file_002.qvd......)

Like that we can run so many task of the same file in parallel (that is not possible to have the same parallelism using QV server)

After that, in the front end all the qvd's will be concatenated together! And that was my question.

Do you have another idea for such topic, and about the concatenate? Your idea work so good, but maybe is not good with many datas.

Thank you, have a nice day!

Paolo.

rnepla83
Partner - Creator
Partner - Creator
Author

Anyone?

Thank you

Not applicable

Hi,

You can use the special caracter * like this

Load *

from  file*.qvd