Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Split single column hierarchy text data into 2 columns while load

Hi All,

I need to load a single column text file having below data in it:

\\MAC\USERS\TEST1\CAT1
      HOME\GENERAL01
      HOME\GENERAL02
      HOME\GENERAL03
\\MAC\USERS\TEST2\CAT2
     HOME\ASHTH01
     HOME\ASHTH02
     HOME\ASHTH03

Need to split the above column into 2 columns in a separate resultant table.

Resultant table content should be

Col1             Col2
----------         ------------------
TEST1          HOME\GENERAL01
TEST1          HOME\GENERAL02
TEST1          HOME\GENERAL03

TEST2          HOME\ASHTH01
TEST2          HOME\ASHTH02
TEST2          HOME\ASHTH03

Thanks in advance,

Raj

6 Replies
MarcoWedel

Hi,

maybe one solution could be:

QlikCommunity_Thread_239273_Pic1.JPG

SET Verbatim = 1;

table1:

LOAD If(LTrim(TextLine)=TextLine, SubField(TextLine,'\',5), Peek(Col1)) as Col1,

    If(LTrim(TextLine)<>TextLine, Trim(TextLine)) as Col2

Inline [

TextLine

"\\MAC\USERS\TEST1\CAT1"

"      HOME\GENERAL01"

"      HOME\GENERAL02"

"      HOME\GENERAL03"

"\\MAC\USERS\TEST2\CAT2"

"    HOME\ASHTH01"

"    HOME\ASHTH02"

"    HOME\ASHTH03"

];

Right Join LOAD Distinct Col2 Resident table1;

hope this helps

regards

Marco

el_aprendiz111
Specialist
Specialist

Hi,

Directory;
LOAD
'TEST1'
AS COL1,
@1 AS COL2
FROM
[..\..\..\..\Desktop\web_Qlik\txt\CAT1.txt]
(
txt, codepage is 1252, no labels, delimiter is '\t', msq);

LOAD
'TEST2'
AS COL1,
@1 AS COL2
FROM
[..\..\..\..\Desktop\web_Qlik\txt\CAT2.txt]
(
txt, codepage is 1252, no labels, delimiter is '\t', msq);

EXIT Script;

VARIOUS.png

Not applicable
Author

Thanks Marco/fer.

marcowedel‌: Getting error saying field not found - <TextLine>

Not applicable
Author

Getting error saying field not found - <TextLine>

MarcoWedel

didn't get any errors in my example.

Can you share your script to look for the reason of this behaviour?

Anil_Babu_Samineni

Can you elaborate more.  What are these

\\MAC\USERS\TEST1\CAT1

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful