Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
mr_novice
Creator II
Creator II

File management in script

Hi All!

Sorry for my bad subject - lack of fantasy. I have a problem and would like a suggestion from the community.

I receive files every day into a folder that I load into a QVD file. I do a loop through all new daily files and concatenate with the QVD file and save it. This happens every day and the QVD is growing like an incremental file. This works fine. But sometimes somebody at the finance department does something wrong and the file contains wrong figures. When they fix the problem the source system creates a new file for the same period, usually same date as the old file, and that file is sent to the import folder. Now this creates a problem, because I have to remove the rows that where sourced from the old file and replace with the rows contained in the new file.

I want to automate this but dont know how to begin.

My idea is this: Loop through the folder with the new files. Save file names in a temporary table. Compare these new file names with previously imported file names in the QVD file and if same name appears delete all rows in QVD that are sourced from the file name (each row contains information about the file name that it was sourced from). Then just import all new files and concatenate with QVD file.

Would you this in another way?

What I have done so far is:

Let vPath_Files = 'C:\\MyInFolder\';

Let vPath_QVD = 'C:\\MyQVDFolder\';

for each File in Filelist('$(vPath_Files)*');

     Temp_Infile:

          LOAD '$(File)' as Name

          Autogenerate 1;

NEXT File

Temp_QVD_File:

LOAD Filename FROM $(vPath_QVD)\Verifications.qvd(qvd);

Now how do I do the comparison? What I want to have is a Temp_QVD_File without the values of Temp_Infile.

Well I dont know how to proceed so any suggestion is helpful. You probably know other ways to do this.

Br

Cris

1 Solution

Accepted Solutions
mr_novice
Creator II
Creator II
Author

Solved this. Im tired so I didn't think....

I used the exists function when loading the QVD file. Dont need to do several loads either.

View solution in original post

1 Reply
mr_novice
Creator II
Creator II
Author

Solved this. Im tired so I didn't think....

I used the exists function when loading the QVD file. Dont need to do several loads either.