Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
suryaa30
Creator II
Creator II

Block Loading a data from File. Using loop

Hi All,

I have a text file with blocks of data. If the first line is starting with a number and 8th value of the string has '#' then it is my header.

The records below that corresponds to that Value.These are '*' delimited. There can be any number of records until next header comes.

Can someone help create a for loop for this load. Attached text file.

Input Format:

QlikC.JPG

Output to be Loaded in Qlik:

Qlikg.JPG

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

No need for a loop. You can do it like this:

Temp:

LOAD

If(IsNum(Left(@1, 1)) And Mid(@1, 8, 1) = '#', @1, Peek(Field1)) as Field1,

If(IsNum(Left(@1, 1)) And Mid(@1, 8, 1) = '#', 'X', @1) as Data

FROM

(txt, codepage is 1252, no labels);

Result:

LOAD Field1,

SubField(Data, '*', 1) as Field2,

SubField(Data, '*', 2) as Field3,

SubField(Data, '*', 3) as Field4,

SubField(Data, '*', 4) as Field5

Resident Temp

Where Data <> 'X';

DROP Table Temp;


Capture.PNG


Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

1 Reply
jonathandienst
Partner - Champion III
Partner - Champion III

No need for a loop. You can do it like this:

Temp:

LOAD

If(IsNum(Left(@1, 1)) And Mid(@1, 8, 1) = '#', @1, Peek(Field1)) as Field1,

If(IsNum(Left(@1, 1)) And Mid(@1, 8, 1) = '#', 'X', @1) as Data

FROM

(txt, codepage is 1252, no labels);

Result:

LOAD Field1,

SubField(Data, '*', 1) as Field2,

SubField(Data, '*', 2) as Field3,

SubField(Data, '*', 3) as Field4,

SubField(Data, '*', 4) as Field5

Resident Temp

Where Data <> 'X';

DROP Table Temp;


Capture.PNG


Logic will get you from a to b. Imagination will take you everywhere. - A Einstein