Splitting the row
Moderators: chulett, rschirm, roy
Splitting the row
Hello
I have a requirement where i will be getting the row such as
1234^;abcdefgh^;bc^;d^;efg^;rghu^;klmn^;bcd
each field delimited by ^;
Is there a way that i can extract each field by using Field function.
I tired using the Field function but it didnt work .Earlier they used the single Field separator (;) but noe they came up with field separator as (^;).
Does the Filed function work?
thanks
I have a requirement where i will be getting the row such as
1234^;abcdefgh^;bc^;d^;efg^;rghu^;klmn^;bcd
each field delimited by ^;
Is there a way that i can extract each field by using Field function.
I tired using the Field function but it didnt work .Earlier they used the single Field separator (;) but noe they came up with field separator as (^;).
Does the Filed function work?
thanks
The Field function works fine but it does require a single character delimiter, just like the way the Column Import stage does. So you have at least two choices that comes to my mind.
1. Pre-process the file to change all occurrences of those two characters to a single character that you are certain does not occur otherwise in the data.
2. Pick one of the two characters as the Field() delimiter and then trim the other from the data. So, if you used "^" as the delimiter, you'd need to trim any leading ";" from the data the Field function retrieved. Of course, this assumes that you would never find a "^" by itself as data.
This has been discussed before, so I'm sure there's other good advice already out there.
1. Pre-process the file to change all occurrences of those two characters to a single character that you are certain does not occur otherwise in the data.
2. Pick one of the two characters as the Field() delimiter and then trim the other from the data. So, if you used "^" as the delimiter, you'd need to trim any leading ";" from the data the Field function retrieved. Of course, this assumes that you would never find a "^" by itself as data.
This has been discussed before, so I'm sure there's other good advice already out there.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Worth logging in today, then, wasn't it? The same thing applies at the record level - to specify DOS-style (two-character) record delimiter, you need to replace Record Delimiter property with Record Delimiter String property.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Right, know about the DOS record delimiter, just forgot about the field delimiter string as an option. Am I missing something with the Column Import stage as well, does it have the same 'delimiter string' option? Not somewhere where I can check tonight.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 12
- Joined: Wed Oct 03, 2007 9:11 am
- Location: London
Re: Splitting the row
dodda wrote:Hello
I have a requirement where i will be getting the row such as
1234^;abcdefgh^;bc^;d^;efg^;rghu^;klmn^;bcd
each field delimited by ^;
Is there a way that i can extract each field by using Field function.
I tired using the Field function but it didnt work .Earlier they used the single Field separator (;) but noe they came up with field separator as (^;).
Does the Filed function work?
thanks
Hello dodda,
A Simple work around , replace ^; using UNIX tr or sed command with ; character
You can execute these command using in build Before Sub routines ExecSH
Thanks
Regards
Raga
Raga