Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
bramvdpoel
Contributor III
Contributor III

Multiple spaces in field

Hi,

Can i reduce  multiple spaces in a field in the loading script?

Field value from the data is: 165/70TR13  APLUS TL A606                      (NEU) 79T *E*

I would like it to be: 165/70TR13  APLUS TL A606 (NEU) 79T *E*

Directory;
LOAD [VDB Articlenr.] as VDBArtikel,
[EAN code] as EAN,
Brand as Merk,
Measurecode as Maat,
Vehicle,
Season,
num([KB price]) as BrutovdBan,
num([Netto Price]) as Netto,
num([Netto Price])*2 as BrutoDubbel,
[Article description] as Omschrijving,
Upper(Brand & Season) as Match
FROM
[..\..\Temp\266032_1.csv]

1 Solution

Accepted Solutions
Colin-Albert

You can nest multiple replace statements so if the result of the first replace is two spaces, they are replaced again.

replace(replace(replace(replace(replace(Field,'  ',' ') ,'  ',' ') ,'  ',' ') ,'  ',' ') ,'  ',' ') 

View solution in original post

5 Replies
OmarBenSalem

try : 

replace(Field,'  ',' ') 

bramvdpoel
Contributor III
Contributor III
Author

Doesn't work, then double spaces become a single space. When there are 10 double spaces it converts into 5 single spaces.

Anil_Babu_Samineni

I am assuming that field value from VDBArtikel. Try the attachment using Mapping table. You can reload using the correct path

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
sunny_talwar

One way could be to use something like this

Table:
LOAD Concat(Field, ' ', Num) as Field;
LOAD Field,
	 RecNo() as Num
Where Len(Trim(Field)) > 0;
LOAD SubField(Field, ' ') as Field;
LOAD * INLINE [
    Field
    165/70TR13  APLUS TL A606                      (NEU) 79T *E*
];
Colin-Albert

You can nest multiple replace statements so if the result of the first replace is two spaces, they are replaced again.

replace(replace(replace(replace(replace(Field,'  ',' ') ,'  ',' ') ,'  ',' ') ,'  ',' ') ,'  ',' ')