Loading data into Qlik Sense

This section describes how to load data into your Qlik Sense application, which is done by executing load scripts.

The load script connects a Qlik Sense app to a data source and loads data from the data source into the Qlik Sense app. When you have loaded the data, it is available to the app for analysis.

Declare an application

Declare the application before you start to work with scripts.

Example: Get a new empty script with localized information

            IApp application = location.App(newAppIdentifier);

Getting a new script

Get a new, empty script with localized information.

Example: Get a new empty script with localized information

            string localizationScript = application.GetEmptyScript();

Creating a custom script

Create a new custom script from scratch.

Example: Creating a new custom script from scratch

            string newScript = localizationScript + "LOAD RowNo() AS value, 1 AS myDimension AUTOGENERATE 300;";

Setting a script

After you have gotten your script or created a new script, you can set the current Qlik Sense application script.

Example: Set the current Qlik Sense application script

            application.SetScript(newScript);

Getting the current application script

You can get the current script stored in the application.

Example: Get the current script stored in the Qlik Sense app

            string currentScript = application.GetScript();

Loading data

After the script has been set, you must reload the data by executing the current application script.

Example: Reload script

            var didReload = application.DoReload();

Loading data with progress

The method GetProgress can be used for time consuming engine-processes. The key is to use an AsyncHandle and to call GetProgress with that handle.

Example: The progress of a reload task.

       AsyncHandle reloadHandle = new AsyncHandle("reload");
	var reloadTask = app.DoReloadAsync(reloadHandle, OnReloaded);
	bool doWork = true;
	while (doWork)
	{ 	
		var progress = await app.Session.Hub.GetProgressAsync(reloadHandle); 		
		Console.WriteLine("Progress: " + progress.TransientProgress + " Finished : " + progress.Finished); 
		if (progress.Finished) doWork = false; System.Threading.Thread.Sleep(1000); // Give the qlik engine time to work before we check the progress again. 	
	}	

For more information, see the example Reloader_NTLM.zip available on Github.

Save the application

Your session need to be saved before you can see it in the application.

Example:  

		application.DoSave();

Did this information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?