Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
viveksingh
Creator III
Creator III

How to remove spaces in qlikview script.

Hi Experts,

I have a qlikview script  where I'm reading from QVS file. I'm getting spaces in script log.  I want to remove the spaces which is appearing in script.  Below is the screen shot.

clipboard_image_0.png

 

Please help on the above

Labels (3)
1 Solution

Accepted Solutions
atoz1158
Creator II
Creator II

Hi

You could also try the following, note there is a funny non-space char at the beginning of the first line of your test log that is the reason for the PurgeChar()

 

RAWLOG:
NoConcatenate
LOAD PurgeChar(Trim([@1:n]),chr(65279)) as Log_Line
FROM [Test log.log]
(fix, utf8, no labels);

LOG:
NoConcatenate
LOAD
Left(Log_Line,10) as Load_Date,
Mid(Log_Line,12,8) as Load_Time,
Left(Log_Line,19) as Date_Time,
Mid(Log_Line,20,5) as PID,
Trim(Mid(Log_Line,25)) as Description
Resident RAWLOG;

DROP Table RAWLOG;

 

Regards

Adrian

 

 

View solution in original post

12 Replies
viveksingh
Creator III
Creator III
Author

@rwunderlich  Need your suggestion on this please. 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Those spaces are inserted by the logger to indicate you are in nested code. 

If you want to remove those leading spaces when loading the log, use the Trim() function.

-Rob

viveksingh
Creator III
Creator III
Author

Thanks for the reply. 

I use trim function. Still getting the same. 

clipboard_image_0.png

 

Data after loading:

clipboard_image_1.png

Ksrinivasan
Specialist
Specialist

hi,

 

can you attach your file to do test,

K. Srinivasan.

viveksingh
Creator III
Creator III
Author

 

I'm unable to upload txt file. attched in zip format. please un zip and load

Ksrinivasan
Specialist
Specialist

 

hi,

before execute your LOAD, you can execute below Statement,

TRIM:
LOAD
@1,
@2,
@3,
@4
FROM [lib://TEST_CASE/Test log.log]
(txt, utf8, no labels, delimiter is spaces, msq);

Store TRIM into [lib://TEST_CASE/Viviksingh.txt] (txt);

then use Viviksingh.txt as source file of your Script,

i attached output in text format, it has no indented space in front of log lines,

 

K. Srinivasan.

viveksingh
Creator III
Creator III
Author

Thanks for the reply. We should not change the input file as these are the logs generated by qlikview. 

 

Please let me know if there is any other way. 

Ksrinivasan
Specialist
Specialist

Hi,

Just you copy and past below Script as Given, just change your file path,

TEMP:
load
*,
Mid(YES_01,1,10) AS LOAD_DATA,
Mid(YES_01,11,8) AS LOAD_TIME,
Mid(YES_01,1,18) AS Date_Time,
Mid(YES_01,19,24) AS PID,
Mid(YES_01,25,100) AS Description,
LEFT(YES_01,10) as DTS;
LOAD
*,
DATE(LEFT(YES_01,10),'DD-MM-YYYY') as CHE;

LOAD
*,
Replace(YES,'','') as YES_01;

LOAD
*,
Replace(TEST,' ','') as YES;

LOAD [@1:n] as TEST

FROM
[C:\Users\Ksrinivasan\Desktop\Cali\Test log.QVS.log]
(fix, utf8, no labels);

Result Below:

clipboard_image_0.png

 

K. Srinivasan.

 

atoz1158
Creator II
Creator II

Hi

You could also try the following, note there is a funny non-space char at the beginning of the first line of your test log that is the reason for the PurgeChar()

 

RAWLOG:
NoConcatenate
LOAD PurgeChar(Trim([@1:n]),chr(65279)) as Log_Line
FROM [Test log.log]
(fix, utf8, no labels);

LOG:
NoConcatenate
LOAD
Left(Log_Line,10) as Load_Date,
Mid(Log_Line,12,8) as Load_Time,
Left(Log_Line,19) as Date_Time,
Mid(Log_Line,20,5) as PID,
Trim(Mid(Log_Line,25)) as Description
Resident RAWLOG;

DROP Table RAWLOG;

 

Regards

Adrian