forked from ChristofSchwarz/QlikScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_all_qvd.txt
73 lines (62 loc) · 2.24 KB
/
load_all_qvd.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Script by Christof Schwarz ([email protected])
// Version: 13-Jan-2015
//
// Description:
// This include-script will load all tables which together
// comprise a data model formerly saved with my other script
// "STORE_ALL_TABLES.txt". It checks .meta.txt files for
// each QVD file as well to make sure the save checksum is
// the same for all QVD files. It throws an error if not
// (which indicates that something went wrong during store).
//
// Parameters needed:
// provide two variables with respective content:
// "vTableQVD_LibConnect" and "vTableQVD_Prefix"
//
// Examples:
/*
LET vTableQVD_LibConnect = 'lib://QVDs (qtsel_csw)/BINARY';
LET vTableQVD_Prefix = DocumentTitle();
*/
TRACE [*** LOAD ALL TABLES ***];
// Check if 2 parameters are provided correctly
IF NOT '$(vTableQVD_LibConnect)' LIKE 'lib://*' THEN
Error: Invalid variable vTableQVD_LibConnect content.;
END IF
IF Len('$(vTableQVD_Prefix)' < 2 THEN
Error: Invalid variable vTableQVD_Prefix content.;
END IF
TRACE [*** PARAMETERS: ***];
TRACE [vTableQVD_LibConnect = $(vTableQVD_LibConnect)];
TRACE [vTableQVD_Prefix = $(vTableQVD_Prefix)];
IF NOT WildMatch(vTableQVD_LibConnect, '*/', '*\') THEN
// Add missing trailling slash to the lib path
LET vTableQVD_LibConnect = vTableQVD_LibConnect & '/';
END IF;
// Create empty table
$QVDMETADATA: LOAD * INLINE [$QVDFILENAME, $QVDCHECKSUM];
FOR EACH vTableQVD IN FileList(vTableQVD_LibConnect & vTableQVD_Prefix & '^*.qvd')
LET vTableName = QvdTableName(vTableQVD);
TRACE [Load $(vTableQVD) >> $(vTableName)];
[$(vTableName)]: LOAD * FROM [$(vTableQVD)] (qvd);
LET vTableMetaData = Left(vTableQVD, Len(vTableQVD)-4) & '.meta.txt';
CONCATENATE ($QVDMETADATA)
LOAD
'$(vTableQVD)' AS $QVDFILENAME
,*
FROM
[$(vTableMetaData)]
(txt, utf8, embedded labels, delimiter is '\t', msq);
NEXT vTableQVD;
IF FieldValueCount('$QVDCHECKSUM') > 1 THEN
Error: The QVDCHECKSUM is not identical in the .meta.txt of the QVD folder;
ELSE
vQVDCheckSum = FieldValue('$QVDCHECKSUM', 1);
TRACE [*** DONE LOADING ALL QVD. ***];
TRACE [$QVDCHECKSUM = $(vQVDCheckSum)];
END IF
// delete temporary variables
LET vTableQVD = Null();
LET vTableName = Null();
LET vTableMetaData = Null();
LET vQVDCheckSum = Null();