Field from a word
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 246
- Joined: Mon Jun 30, 2008 3:22 am
- Location: New York
- Contact:
Field from a word
My requirement is to split the incoming string based on the no. of words.
If the source data has four words, my output should be C1 - first 2 words and C2 - next 2 words.
If there are 7 words, C1 - 3 words and C2 - next 4 words.
I can count the no. of spaces and div by 2 and find the word from which the string should be split.
As Field fn will not accept more than one char as delimiter, If it is server, I can use the Ereplace and replace that word with @FM and use @FM as delimiter in Field fn to extract first part.
Is there a similar kind of fn in parallel that I can use to achieve this?
I believe convert can only replace single char.
If the source data has four words, my output should be C1 - first 2 words and C2 - next 2 words.
If there are 7 words, C1 - 3 words and C2 - next 4 words.
I can count the no. of spaces and div by 2 and find the word from which the string should be split.
As Field fn will not accept more than one char as delimiter, If it is server, I can use the Ereplace and replace that word with @FM and use @FM as delimiter in Field fn to extract first part.
Is there a similar kind of fn in parallel that I can use to achieve this?
I believe convert can only replace single char.
Arun
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Participant
- Posts: 246
- Joined: Mon Jun 30, 2008 3:22 am
- Location: New York
- Contact:
Anbu, creating the delimiter is my problem. I cannot replace the entire word with @FM using convert nor I can use that word as delimiter in the field function.anbu wrote:Use Field function to extract the words based on the delimiter
In server I can write the derivation like,
Field(Ereplace('Arun Kumar','Kumar',@FM),@FM,1),
Is there a similar function/way in parallel?
Arun
If i understand your requirement
You can have two links from transformer one constraint as space count equal to 4 and other for 7. In second link write derivation like above to get 3 and 4 words from your input
Code: Select all
wrds="A B C D"
C1=Field(wrds," ",1) : Field(wrds," ",2)
C2=Field(wrds," ",3) : Field(wrds," ",4)
You are the creator of your destiny - Swami Vivekananda
-
- Participant
- Posts: 246
- Joined: Mon Jun 30, 2008 3:22 am
- Location: New York
- Contact:
No Anbu. My requirement is to split the input string into two, if the words are not equal maximum words should be on the second column. No. of words are dynamic in the input.
Eg., Str = "One Two Three Four"
O/P: C1 = 'One Two" C2 = "Three Four"
If Str = "One Two Three Four Five"
O/P: C1 = 'One Two" C2 = "Three Four Five"
If Str = "One Two Three Four Five Six Seven"
O/P: C1 = 'One Two Three" C2 = "Four Five Six Seven"
And no restriction for No. of words in the input. Hope this is clear.
Eg., Str = "One Two Three Four"
O/P: C1 = 'One Two" C2 = "Three Four"
If Str = "One Two Three Four Five"
O/P: C1 = 'One Two" C2 = "Three Four Five"
If Str = "One Two Three Four Five Six Seven"
O/P: C1 = 'One Two Three" C2 = "Four Five Six Seven"
And no restriction for No. of words in the input. Hope this is clear.
Arun
-
- Participant
- Posts: 246
- Joined: Mon Jun 30, 2008 3:22 am
- Location: New York
- Contact:
Thanks Sainath. I found that.arunkumarmm wrote:Anbu, creating the delimiter is my problem. I cannot replace the entire word with @FM using convert nor I can use that word as delimiter in the field function.anbu wrote:Use Field function to extract the words based on the delimiter
In server I can write the derivation like,
Field(Ereplace('Arun Kumar','Kumar',@FM),@FM,1),
Is there a similar function/way in parallel?
Arun
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 246
- Joined: Mon Jun 30, 2008 3:22 am
- Location: New York
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Wait a sec, I have a different idea.
When you say your delimiter is of more than one character, does it imply 2 identical characters or different values.
For example, do you see
These remove the need for EReplace. But includes one extra step.
When you say your delimiter is of more than one character, does it imply 2 identical characters or different values.
For example, do you see
Or'ThisbbIsbbAbbTestbbString'
If it is the first case, you can take fields of odd numbers together or trim your fields before concat. In second case, you can use your first delimiter ('X' in this case') in your field function and remove leading 'Y's from your non-first columns.'ThisXYIsXYAXYTestXYStringXY'
These remove the need for EReplace. But includes one extra step.
-
- Participant
- Posts: 246
- Joined: Mon Jun 30, 2008 3:22 am
- Location: New York
- Contact:
Ray, I quoted that field fn will not accpet more than one char as delimiter.ray.wurlod wrote:The requirement does not specify multiple-character delimiters. ...
I'm sorry if that was not clear.
As Field fn will not accept more than one char as delimiter, If it is server, I can use the Ereplace and replace that word with @FM and use @FM as delimiter in Field fn to extract first part.
Is there a similar kind of fn in parallel that I can use to achieve this?
I believe convert can only replace single char.
Arun
-
- Participant
- Posts: 246
- Joined: Mon Jun 30, 2008 3:22 am
- Location: New York
- Contact:
Sai, Thanks for your reply!Sainath.Srinivasan wrote:Wait a sec, I have a different idea.
When you say your delimiter is of more than one character, does it imply 2 identical characters or different values.
For example, do you see'ThisbbIs ...
I dont have any specific delimiter. I want to split the incoming string based on the no. of words. So I want to use one of those words as a delimiter to split it.
Eg.,
If Str = "One Two Three Four Five Six Seven"
O/P should be: C1 = 'One Two Three" C2 = "Four Five Six Seven"
What I'm trying to do is, Count(Str,' ') = 6, 6/2 = 3, so my column 1 should have 3 words. So, so replace the 4th word with @FM, use it as delimiter and extract the first three words.
Arun