Hi All,
Does anyone know if there is a way to remove data from a qvw with a command line but by keeping the field names.
I have tried the following...
C:\Program Files\QlikView\qv.exe /nodata C:\Folder\File.qvw
but this removes ALL data including field names which then loses all field formats set in the document properties.
I basically want a way of doing the same thing as FILE>REDUCE DATA>REMOVE ALL VALUES but with a command line instead.
Does anyone know a way?
Thanks
Hi
So you want to save the layout for backup purposes.
Have you considered using the -prj method? This saves the layout complete with formats (but no variable values).
To create the layout backup:
To recreate from the backup:
No special step to run a VBS script...
Hope that helps
Jonathan
If you still need the command line option, you could add this code at the end of your script which seems to do the trick - it just inner joins each table with null values. Just pass the parameter in the cmd line to trigger it ...
If '$(vUnload)' = 1 then
For t = NoOfTables()-1 to 0 step -1
tbl = TableName(t);
fld = FieldName(1,'$(tbl)');
let cmd = 'Null() as $(fld)';
inner join ($(tbl))
Load $(cmd) autogenerate 1;
next t;
End If;
vUnload = 0;
C:\Program Files\QlikView\qv.exe /r /vvUnload=1 C:\Folder\File.qvw.
flipside
Use this VBS:
Set MyApp = CreateObject("QlikTech.QlikView")
Set MyDoc = MyApp.OpenDoc("Sample.qvw","","")
Set ActiveDocument = MyDoc
MyDoc.RemoveAllData
MyDoc.SaveAs("Sample.qvw")
MyDoc.GetApplication.Quit
Set MyDoc = Nothing
Set MyApp = Nothing
if it is for backup purposes why dont you try the reduce option in the QMC and backup the qvw produced by the backup?
the only thing that you will loose is the script , but you will have the app with the data and the full GUI objects.
sounds weird but i think its a creative way to do it with just using the qmc
Hi,
Inspired by flipside's response, I try doing something like this:
Create a variable vExit with no value. Then put this code after initial SET definitions:
if $(vExit) = 1 then
trace('Stopping Data Load');
LET vExit = 0;
EXIT Script;
ELSE
trace('Running Script');
ENDIF
Then pass vExit=1 in command line (from qlikview folder): Qv.exe /r /vvExit=1 c:\Path\to\Sample.qvw
This way you should get a qvw with no data at all. I am rather new to QlikView and still checking if this method has any downsides, but I hope to use it with SVN synch (before commit).
@
That works fine. I've implemented that myself. The disadvantage is that you need to modify the script of the document first.
Another solution I have used is creating an excel file with a list of file names and run a vba macro in excel to create a Qlikview instance, open each qvw file in turn, remove its data, and finally save and close the file.
Thanks, it works fine.
Adriano
can you please share your sample script, even I too need this coding for me.
Thanks
Hi Srinivasan,
the code is:
Set MyApp = CreateObject(QlikTech.QlikView")
Set MyDoc = MyApp.OpenDocEx("sourcePathFile&docFileName", 0, False)
Set ActiveDocument = MyDoc
MyDoc.RemoveAllData()
MyDoc.SaveAs("destinationPathFile&docFileName")
MyDoc.CloseDoc()
MyApp.Sleep 2000
MyApp.Quit()
Set MyDoc = Nothing
Set MyApp = Nothing
There are some little difference due to my Windows Server (release 2012). The first is MyDoc.GetApplication.Quit in
MyDoc.CloseDoc() and MyApp.Quit() and the secod is MyApp.Sleep 2000.
It is due to the information load times at the interface opening QlikView Desktop.
Bye
Adriano
But when I am using at the QV script, I am getting object can not be create by Qlikview tech..