About EasyMorph Tutorials & Examples Web-help

QVD file metadata


#1

Hi,

Could we have an import function that extract the metadata of a QVD file like in EasyQlik QViewer ?
This would be helpful to migrate a full datastore of QVD files to another file format for storage purpose.

Regards


#2

I would be reluctant adding a special transformation for it because it would be very rarely used.

We can try adding an option to the "Import from XML file" transformation that would stop reading file on first occurrence of zero-byte (or other character illegal in XML). That would allow reading XML headers of QVD files and extracting metadata from them.

Or maybe write a short Powershell script that would extract the XML header from a QVD file (i.e. strip the binary data), and then call it from EM before loading the XML header.

Let me give it a thought.


#3

The option way is great. I tried to extract the XML part as a text file and then read it as an XML file but I didn't succeed to find a workaround for the double quote in the generated text file.


#4

I've quickly made a command line utility to extract xml metadata from QVD files: QVD_Metadata.zip (4.0 KB)

Put it next to morph.exe (it needs FSharp.Core.dll).

Usage:
QVD_Metadata.exe file.qvd

It creates file.xml with the metadata header.

The source code (F#):

open System.IO

[<EntryPoint>]
let main argv = 
	try
		if argv.Length <> 1 then
			failwith "Invalid arguments. Usage: QVD_Metadata.exe file.qvd"

		let pathQVD = argv.[0]
		let pathXML = pathQVD.Replace(".qvd", ".xml")

		use fileXML = new BinaryWriter(File.Create pathXML)

		seq {
			use fileQVD = new BinaryReader(File.Open(pathQVD, FileMode.Open, FileAccess.Read))

			// A QVD file must have a zero byte therefore the end of file will never be reached.
			while 1=1 do
				yield fileQVD.ReadByte()
		}
		|> Seq.takeWhile (fun b -> b <> (byte 0))
		|> Seq.iter fileXML.Write

		0
	with
	| ex ->
		printfn "Error:%s" ex.Message
		1

#5

Thanks,
So I can consider to migrate my knowledge store out of QVD files.

Regards

CVO