Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi , i have a file (.txt ) , and i want to load the information in it into a variable . The structure of this file is :
201305
Hi Kamy,
Please use the code below. Remember to put a field name (Variables in the exaple) into the first row of your text file.
text file structure:
Variables
201403
201405
...
Qlikview script:
Variables:
LOAD Variables FROM c:\file.txt (txt, utf8, embedded labels, delimiter is '\t', msq); //here all the file rows are readed
LET Variable1 = peek( 'Variables', 0 ); //0 is the first row
LET Variable2 = peek( 'Variables', 1 ); //1 is the second row
...
If you need a lot of variables do a loop and use an incremental variable into the second parameter instead a number.
Let me know if it works.
Regards.
Hi Kamy,
Please use the code below. Remember to put a field name (Variables in the exaple) into the first row of your text file.
text file structure:
Variables
201403
201405
...
Qlikview script:
Variables:
LOAD Variables FROM c:\file.txt (txt, utf8, embedded labels, delimiter is '\t', msq); //here all the file rows are readed
LET Variable1 = peek( 'Variables', 0 ); //0 is the first row
LET Variable2 = peek( 'Variables', 1 ); //1 is the second row
...
If you need a lot of variables do a loop and use an incremental variable into the second parameter instead a number.
Let me know if it works.
Regards.
yes that's correct , please i need to know if i can do like this :
if (peek( 'Variables', 0 )<=9, //here I want to concatenate the variable with zero)
for exemple : if the value is 3 it should become 03
thks for your help
Hi Kamy,
No, you can't do it directly with the PEEK sentence but using a conditional will work (if you need to do a loop it will work too):
Variables:
LOAD Variables FROM c:\file.txt (txt, utf8, embedded labels, delimiter is '\t', msq);
LET Variable1 = peek( 'Variables', 0 ); //0 is the first row
LET Variable2 = peek( 'Variables', 1 ); //1 is the second row
IF $(Variable1) <=9 THEN
LET Variable1 = 0 & $(Variable1);
ENDIF
Let me know if this works.
Regards.