Field Seperator - Multiple Spaces

One Star tt1
One Star

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,
One Star

Re: Field Seperator - Multiple Spaces

Hi,
You can use just one space as a separator and check trim all columns in your tFileInputDelimited advanced settings.
Regards,
Youssef
One Star tt1
One Star

Re: Field Seperator - Multiple Spaces

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.
One Star

Re: Field Seperator - Multiple Spaces

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
One Star tt1
One Star

Re: Field Seperator - Multiple Spaces

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.
One Star

Re: Field Seperator - Multiple Spaces

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
Employee

Re: Field Seperator - Multiple Spaces

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)
One Star tt1
One Star

Re: Field Seperator - Multiple Spaces

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.
One Star

Re: Field Seperator - Multiple Spaces

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
One Star tt1
One Star

Re: Field Seperator - Multiple Spaces

Thanks Volker, I'll give it a go