Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Zurich on Sept 24th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
sspawar88
Creator II
Creator II

Script for check Table Structure

Hi Folks,

Thanks in advance.

How I create a loop to check whether I'm getting right table structure or not?

In one folder on server 'E:\Data\..' i get 3 excel file which moved in 'D:\Data\..' by batch files. from  'D:\Data\..' Qlikview starts to fetch data.

but before moving in 'D:\Data\ i want check the structure of files. so how can i write script to check structure?

Emp:

keyemp_idemp_name
1EMP1A
2EMP2B
3EMP3c

Source:

keydatesource location
122/4/2016postgresUk
215/7/2016teradataUs
312/3/2015oracleSng

Period:

YearMonthdayMng_idkey
2016jan35671
2017dec43452
2017feb52343
1 Reply
zhadrakas
Specialist II
Specialist II

You can read the XML metadata of the QVD file to check field existance such as this example

QvdFieldHeader:
LOAD FieldName
FROM F:\YOURPATH\Emp.qvd (XmlSimple, Table is [QvdTableHeader/Fields/QvdFieldHeader]);

For i = 0 to NoOfRows('QvdFieldHeader')-1

LET vFieldName = peek('FieldName', $(i));
if FieldIndex('FieldName',peek('FieldName', $(i))) > 0 then
Trace 'Field ' & '$(vFieldName)' & ' exists';
LET vStructureOK = true();
else
Trace 'Field ' & '$(vFieldName)' & ' is missing';
LET vStructureOK = false();
end if;

next

if $(vStructureOK) = true() Then
//Load from QVD
ELSE
//....
END IF

//cleanup
LET vFieldName =;
LET vStructureOK =;

EXIT Script;