Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Contributor II

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

1 Solution

Accepted Solutions
Highlighted
Contributor II

Re: How to remove spaces in qlikview script.

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
Highlighted
Contributor II

Re: How to remove spaces in qlikview script.

@rwunderlich  Need your suggestion on this please. 

Highlighted
MVP & Luminary
MVP & Luminary

Re: How to remove spaces in qlikview script.

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

Highlighted
Contributor II

Re: How to remove spaces in qlikview script.

Thanks for the reply. 

I use trim function. Still getting the same. 

clipboard_image_0.png

 

Data after loading:

clipboard_image_1.png

Highlighted
New Contributor III

Re: How to remove spaces in qlikview script.

hi,

 

can you attach your file to do test,

K. Srinivasan.

Highlighted
Contributor II

Re: How to remove spaces in qlikview script.

 

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

Highlighted
New Contributor III

Re: How to remove spaces in qlikview script.

 

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.

Highlighted
Contributor II

Re: How to remove spaces in qlikview script.

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. 

Highlighted
New Contributor III

Re: How to remove spaces in qlikview script.

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.

 

Highlighted
Contributor II

Re: How to remove spaces in qlikview script.

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