Page 1 of 1

Single column to multiple

Posted: Tue Sep 09, 2014 1:12 pm
by sam334
All,
Need suggestion on splitting one columns to multiple.
I have one column like:

Code: Select all

Column1
12:10:07: Dialing
12:10:07: Connecting
12:10:07: ABC: abc:9433769782$100.88.77.0:8787
12:10:09: ABCD: 0000
How can we split the column into two columns. Can we use any substring function.

Code: Select all

Column 1 (Time),    Column 2(Description)
12:10:07:           Dialing
12:10:07:           Connecting
12:10:07:           ABC: abc:9433769782$100.88.77.0:8787
12:10:09:           ABCD: 0000
Thanks and appreciate your help. Source data is coming from sequential file.

Posted: Tue Sep 09, 2014 1:23 pm
by chulett
Investigate the Field() function which can extract fields from a delimited string. Tell it you have a ":" delimited string and you want the fourth field and all fields after that.

I'd rather you do this on your own rather than simply hand off the syntax as it's a better learning experience that way. Teach a man to fish and all that. :wink:

Posted: Tue Sep 09, 2014 1:30 pm
by sam334
Thanks Craig. That is always true. Spoon feeding is not at all a good practice. Do we have field function in server jobs. I thought it is in parallel only.

Posted: Tue Sep 09, 2014 1:35 pm
by chulett
I wouldn't have suggested it if it wasn't in Server jobs, they were my bread and butter for many years. :wink:

Posted: Tue Sep 09, 2014 2:03 pm
by sam334
Opps..Did not know that.. Just thought to ask as something while looking the threads I miss the functions between parallel and server.

Posted: Tue Sep 09, 2014 5:13 pm
by ray.wurlod
Seems to me (based on your example) that the more appropriate delimiter to use in your Field() function is " " rather than ":".

Posted: Tue Sep 09, 2014 10:58 pm
by chulett
Sure... assuming it's actually a space. And I thought using the colon as the delimiter would be more illustrative of the function's use. :wink:

Posted: Wed Sep 10, 2014 2:47 am
by priyadarshikunal
If the first column is fixed width as it seems from the example, you can try left() and right() functions as well.