Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a folder with the following files:
General_Accounts_1.qvd
General_Accounts_2.qvd
Specific_Accounts_3.qvd
Specific_Accounts_4.qvd
Summary.qvd
Work.qvd
What I need is to empty all files in bold (Starting with General_Accounts_* and Specific_Accounts_*) by script.
I need to do that to initialize the files with 0 kb because then I have to run a process that stores the data I need.
Do you know how to do that? (Please, I don't need macros or CMD commands)
Thank you!!!
see the attachement
I changed 1 line in the sub
WHERE 0=1 //Exists(Dim1) |
look at the last approach here
QlikTip #30: How to delete existing QVD files via load-script
I am not sure if I understand your question. When you run the process the qvd will get over written automatically.
So for example when you run the script for the first time a file General_Accounts_1.qvd is generated. When you run the script second time, the existing qvd file General_Accounts_1.qvd is over written.
Hope this helps. If not can you please be little specific.
Yes, the problem is that I have a process where I generate multiple QVDs, for example: General_Accounts_1, General_Accounts_2, General_Accounts_3, etcetera. And it can change from time to time. The first run I could get 5 files, the second run maybe one only 3. So I need to make sure to delete the content from all because I don't want to read data from a previous run (because then I use LOAD FROM General_Accounts_* and if I do that on the second run I'd be reading data from files 4 and 5). If I empty all at the beginning I make sure I read only the needed data...
I can't get it to work on my script I get an error on line 62: WHERE
Exists
(Dim1)
see the attachement
I changed 1 line in the sub
WHERE 0=1 //Exists(Dim1) |
Ok got it. Give a try on the below code. I am also attaching a sample app for you to play around.
What this app does is:
1) First it will empty all the QVD's in a sub folder
2) Then it creates two QVDs in the sub folder.
Hope this helps....
SUB EmptyQVDFiles (Path)
//Check file exists
For each File in Filelist ('$(Path)')
IF (NOT isNull(qvdCreateTime('$(File)'))) THEN
//Check if QVD is already empty
IF (qvdNoOfRecords('$(File)') > 0) THEN
//Load the table structure from the existing QVD
//using Where clause which returns no records
Table_Structure:
LOAD
*
FROM '$(File)' (qvd)
WHERE 1<>1;
//Store table Structure back into QVD
STORE Table_Structure INTO '$(File)' (qvd);
DROP TABLE Table_Structure;
End If
End If
Next File
End Sub