Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
TauseefKhan
Creator III
Creator III

How convert text file into tabular format in Qlik sense

I have data in text fiel in below format:

----------NEW TRANSACTON-----------
TRANSACTION DATE : 10:02 AM, 05 Dec 2021
CLIENT ID : Z0119
CLIENT NAME : ABCZ SALE
AMOUNT : 180,650.00
TRANSACTION REF. : 021

I need data in below format:

TauseefKhan_0-1647341880775.png

 

Labels (1)
4 Replies
NitinK7
Specialist
Specialist

try below script

but make sure you have add only delimiter at one time , in your data TRANSACTION DATE : 10:02 AM, 05 Dec 2021

you use same delimiter 2 time. try like TRANSACTION DATE : 10.02 AM, 05 Dec 2021 then  below script  will work 


ABC:

LOAD [TRANSACTION DATE],
[CLIENT ID],
[CLIENT NAME],
AMOUNT,
[TRANSACTION REF.]
FROM
[lib://desk/ss.txt]
(txt, codepage is 28591, embedded labels, delimiter is ':', msq, filters(Transpose()));

MarcoWedel

 

Assuming there are multiple transactions included in one file, one solution might be:

 

MarcoWedel_0-1647367264221.png

using this test file:

MarcoWedel_1-1647367365940.png

 

 

tabTransactFile:
LOAD [@1:n] as Line,
     RangeSum(Peek(TransactID),-([@1:n]='----------NEW TRANSACTON-----------')) as TransactID
FROM [lib://DataFiles/Transactions.txt] (fix, codepage is 1252);

tabTransactTemp:
Generic
Load TransactID,
     SubField(Line,':',1),
     Mid(Line,Index(Line,':')+1)     
Resident tabTransactFile
Where Line<>'----------NEW TRANSACTON-----------';

Drop Table tabTransactFile;

tabTransact:
Load '' as TempField AutoGenerate 0;

FOR i = NoOfTables()-1 to 0 STEP -1
  LET vTable=TableName($(i));
  IF WildMatch('$(vTable)', 'tabTransactTemp.*') THEN
    JOIN (tabTransact) LOAD * RESIDENT [$(vTable)];
    DROP TABLE [$(vTable)];
  ENDIF
NEXT i

Drop Field TempField;

 

 

hope this helps

Marco

TauseefKhan
Creator III
Creator III
Author

When I use Mid() function or this Expression: Mid(Line,Index(Line,':')+1) showing An error occurs: the session has timed out due to inactivity.

TauseefKhan_0-1647406426611.png

 

MarcoWedel

I don't think this error message is related to the Mid() function.

Did you try reopening your session and repeating the test?