Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
userid128223
Creator
Creator

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
Anil_Babu_Samineni

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';

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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

-Rob

Anil_Babu_Samineni

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';

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful