Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

amiumi66
New Contributor III

Load from list of files only if file has data.

i have few text files that gets generated everyday. Header of files gets generated every single time (hence it is not "Zero" in size) however weekend files dont have any data in them. I want to merge those files into 1 file for each.....

Need help writing script.

temptable:

Load 0 as field1 autogenerate 0;

For each vFile in FileList('temp2016*.txt')

if file is greater then 1 record then

concatenate (temptable)

otherwise don't concatenate and move on to next file.

1 Solution

Accepted Solutions

Re: Load from list of files only if file has data.

May be this?

temptable:

Load 0 as field1 autogenerate 0;

For each vFile in FileList('temp2016*.txt');

If NoOfRows('$(vFile)') > 0 Then

Load '$(vFile)' as Field2;

Else If

Concatenate (template)

Load '$(vFile)' as Field2;

Else

Trace 'Error on Script';

2 Replies

Re: Load from list of files only if file has data.

I could probably work up a suggestion. But first question, what is the problem with loading a zero row file in your concatenate?

-Rob

Re: Load from list of files only if file has data.

May be this?

temptable:

Load 0 as field1 autogenerate 0;

For each vFile in FileList('temp2016*.txt');

If NoOfRows('$(vFile)') > 0 Then

Load '$(vFile)' as Field2;

Else If

Concatenate (template)

Load '$(vFile)' as Field2;

Else

Trace 'Error on Script';

Community Browser