Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
tibor_sebok
Partner - Contributor II
Partner - Contributor II

Importing Variables from a file

Hi guys,

I have the following problem: I want to import a lot of variables (~600) from an outer file. With the code below I was able to import them, but for a large group of variables the "Definition" section did not fill up. Tough I think their value (the expressions) are there, because when I hover over the name of the variable, the expression pops up, but just for a second. Could you help me? My I aim is to be able to fill up all the definitions.

My code:

VariableDescription2:
LOAD Name,
     RawValue
FROM
[URL of text file\Variables.txt]
(txt, utf8, embedded labels, delimiter is ',', msq);

// Create variables
for i = 0 to NoOfRows('VariableDescription2') - 1

  let vName = peek('Name', i, 'VariableDescription2'); // Name of the variable
  let $(vName) = peek('RawValue', i, 'VariableDescription2');

next I

Thanks

Tibor

5 Replies
jaibau1993
Partner - Creator III
Partner - Creator III

Hi Tibor! Could you please share a sample of the data (txt with variables) so we can play with it?

Jaime.

balabhaskarqlik

May be these are the reasons:

Have you tried to load few columns to test whether it works?

I am guessing maybe QV can't load some specific character in some columns like below specified.

Character set problems with non-ANSI encoded data files

You may experience problems with character encoding in non-ANSI encoded data files when using an ODBC data connection.

Possible cause 

ODBC data connections do not provide full capabilities for character set encoding.

Proposed action 

Do the following:

    If possible, import the data files using a folder data connection, which supports more options for handling character codes. This is probably the best option if you are loading a Microsoft Excel spreadsheet or a text data file.

tibor_sebok
Partner - Contributor II
Partner - Contributor II
Author

Hi guys,

first of all thanks for the comments. What really interesting is, that when I am loading the variables into an empty application, all of them gets their definition properly. Though when I try to do the same with an application that already has script/data then a great deal of these variable definitions are empty. So I guess it is not the question of formatting, otherwise it would not work in an empty application.

My main object is to use Git with QlikView. What gets problematic though is the handling of variables, where the definitions are handled as data, therefore not taken into consideration by Git. In order to be able to use these definitions, I am storing the variables into a txt file. After recreating the application from the files on GitHub/Gitlib, I am reloading the variables from the txt at the end of the script.

The big problem is, it is not loaded properly when the application itself is not empty.

Any suggestions?

Thanks

Tibor

tibor_sebok
Partner - Contributor II
Partner - Contributor II
Author

Okay,

I managed to get in the variables (most of them) by deleting the previous ones from the GUI Varlable Overview tab. But when I try to reload them via txt or csv, there are a number of variables that are not loaded into the app at all (not even the name).  I've looked into them but they contain the same characters/values as variables that have been properly loaded.Any ideas? What am I doing wrong?

Thanks,


Tibor

marcus_sommer

I would change the following:

- loading these variables before the normal loadings to avoid potential side-effects with already loaded data

- loading the variable-textfile with text(Name) and text(RawValue)

- removing the msq from the fileformat because quite probably there are a lot of (different) quotes within your variables

If this doesn't help completely I would load the variables into an extra table to be able to compare input and output directly. I mean something like this:

for i = 0 to NoOfRows('VariableDescription2') - 1

  let vName = peek('Name', i, 'VariableDescription2'); // Name of the variable
  let $(vName) = peek('RawValue', i, 'VariableDescription2');

  Output:

  load

     $(i) as Counter, peek('Name', i, 'VariableDescription2') as VarName,

     '$(vName)' as VarValueOutput,

     fieldvalue('RawValue', $(i) + 1) as VarValueInput,

     fieldvalue('Name', $(i) + 1) as VarNameInput

  autogenerate 1;

next i

By comparing the differences from the raw-data (looked within an editor like notepad ++) and the input and output in Qlik there should be some pattern/insights visible to hint for the real cause.

- Marcus