Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Field Seperator - Multiple Spaces

Hi,

I have a record that has spaces as seperators, but unfortunately not just one space each time, any number of spaces.

Example

1 2 3 4 5 6 7

Using " " as seperator does not work, so I either need a better seperator or to strip out any unrequired spaces before delimiting, the trouble here is that I still need a single space in order to delimit to stripping all spaces is no good.

Regards,
Labels (2)
9 Replies
youssef2
Contributor
Contributor

Hi,
You can use just one space as a separator and check trim all columns in your tFileInputDelimited advanced settings.
Regards,
Youssef
Anonymous
Not applicable
Author

Youssef,

Thanks for the response. The number of spaces is random, so this will not quite work. I did think of doing several tmap with a StringHandling.EREPLACE(row1.newColumn," "," ") for each number of spaces, but doing this 6/7 times would not be ideal.

Example

1 2 3 4 5
1 2 3 4 5


Cheers,

John.
youssef2
Contributor
Contributor

The number of spaces is random

Yes, but at least you have one space. so define just one space as a separator and trim your columns to remove useless spaces.
Regards,
Youssef
Anonymous
Not applicable
Author

Youssef,

If I use one space as a seperator I end with a new column every time I hit a space

so

1 2 3

becomes

1|2||3

and not

1|2| 3


I'll try to strip out the additional spaces before I delimit.


John.
youssef2
Contributor
Contributor

Sorry, I didn't realize your problem.
You can use tFileInputRegex to retrieve your columns , in your case the regular expression would be like this: "(+)"+"+"+"(+)"
Here, I suppose that you have 2 columns.
Regards,
Youssef
Anonymous
Not applicable
Author

In case Perl users are reading this topic, here comes a difference between Java and Perl. In Perl tFileInputDelimited, you can set the "Field Separator" to :
/ +/

(no quote)
Anonymous
Not applicable
Author

Thanks for your help guys,

In the end I decided to read the file as a one line column delimited by '\n', then using treplace I have set conditions to remove the various number of blank spaces possible and replace with a single space, then an extractdelimited using a single space as the delimiter.

Its now working.

As a product trial I am reworking a series of Ab Initio Graphs, so am probably going to post a few questions.

Thanks again.
Anonymous
Not applicable
Author

Hi,
I have set conditions to remove the various number of blank spaces possible and replace with a single space

sounds complex. You can use (in java) the following code to change your spaces:
stringColumn.replaceAll(" +", " ");

The second parameter could be whatever you want (or need).
Bye
Volker
Anonymous
Not applicable
Author

Thanks Volker, I'll give it a go