Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
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()));
Assuming there are multiple transactions included in one file, one solution might be:
using this test file:
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
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.
I don't think this error message is related to the Mid() function.
Did you try reopening your session and repeating the test?